2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #define MAX_PATH_LEN 1024
18 #define MAX_MSG_LEN 1024
20 #define _STRINGIFY(x) #x
21 #define STRINGIFY(x) _STRINGIFY(x)
23 #define MAX_PATH_LEN_STR STRINGIFY(MAX_PATH_LEN)
24 #define MAX_MSG_LEN_STR STRINGIFY(MAX_MSG_LEN)
26 #define LOG_MODE_NONE 0
27 #define LOG_MODE_FILE 1
29 # define LOG_MODE_STDERR (LOG_MODE_FILE << 1)
30 # define LOG_MODE_DLOG (LOG_MODE_FILE << 2)
33 #define PRINT_INFO_OR_ERROR_INFO(expr, fmt, arg...) \
36 _logger_log_info(""fmt"", ##arg); \
38 _logger_log_err(""fmt"", ##arg); \
41 /* Enumeration for terminal colors. Used in internal _printf() function */
48 /* Sets globally the mode of logging. mode has to be specified as a single or
49 combination of the following defines:
50 LOG_MODE_NONE - no logging;
51 LOG_MODE_FILE - logging to the file;
52 LOG_MODE_STDERR - logging to the standart error stream;
53 LOG_MODE_DLOG - logging to the dlog.
54 For example, set_logging_mode(LOG_MODE_FILE | LOG_MODE_DLOG) call will
55 direct all following logging to both file and dlog daemon */
56 void _logger_set_logging_mode(int mode);
58 /* Sets globally the name of the file for LOG_MODE_FILE logging mode */
59 int _logger_set_file(const char *fname);
61 /* Sets globally the log tag will be used in logging journals like Tizen dlog */
62 int _logger_set_log_tag(const char *tag);
64 /* Functions for corresponding logging: */
65 int _logger_log_info(const char *fmt, ...);
66 int _logger_log_warn(const char *fmt, ...);
67 int _logger_log_err(const char *fmt, ...);
69 /* Function for using instead of standard printf() if coloring is needed */
70 int _printf(_cmd_color_e color, const char *fmt, ...);