Implementation of the test suite for API testing
[platform/core/api/sound-pool.git] / test / logger / logger.h
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #define MAX_PATH_LEN 1024
18 #define MAX_MSG_LEN 1024
19
20 #define _STRINGIFY(x) #x
21 #define STRINGIFY(x) _STRINGIFY(x)
22
23 #define MAX_PATH_LEN_STR STRINGIFY(MAX_PATH_LEN)
24 #define MAX_MSG_LEN_STR STRINGIFY(MAX_MSG_LEN)
25
26 #define LOG_MODE_NONE 0
27 #define LOG_MODE_FILE 1
28 #ifdef LOG_MODE_FILE
29 #    define LOG_MODE_STDERR (LOG_MODE_FILE << 1)
30 #    define LOG_MODE_DLOG   (LOG_MODE_FILE << 2)
31 #endif
32
33 /* Enumeration for terminal colors. Used in internal _printf() function */
34 typedef enum {
35         CMD_COLOR_RED,
36         CMD_COLOR_YELLOW,
37         CMD_COLOR_GREEN
38 } _cmd_color_e;
39
40 /* Sets globally the mode of logging. mode has to be specified as a single or
41    combination of the following defines:
42    LOG_MODE_NONE - no logging;
43    LOG_MODE_FILE - logging to the file;
44    LOG_MODE_STDERR - logging to the standart error stream;
45    LOG_MODE_DLOG - logging to the dlog.
46    For example, set_logging_mode(LOG_MODE_FILE | LOG_MODE_DLOG) call will
47    direct all following logging to both file and dlog daemon */
48 void _logger_set_logging_mode(int mode);
49
50 /* Sets globally the name of the file for LOG_MODE_FILE logging mode */
51 int _logger_set_file(const char *fname);
52
53 /* Sets globally the log tag will be used in logging journals like Tizen dlog */
54 int _logger_set_log_tag(const char *tag);
55
56 /* Functions for corresponding logging: */
57 int _logger_log_info(const char *fmt, ...);
58 int _logger_log_warn(const char *fmt, ...);
59 int _logger_log_err(const char *fmt, ...);
60
61 /* Function for using instead of standard printf() if coloring is needed */
62 int _printf(_cmd_color_e color, const char *fmt, ...);