Add: DBus API for AMB.
[profile/ivi/ico-uxf-utilities.git] / include / ico_log.h
1 /*
2  * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
3  *
4  * This program is licensed under the terms and conditions of the
5  * Apache License, version 2.0.  The full text of the Apache License is at
6  * http://www.apache.org/licenses/LICENSE-2.0
7  *
8  */
9
10 /*========================================================================*/
11 /**
12  *  @file   ico_log.h
13  *
14  *  @brief  debug log function
15  */
16 /*========================================================================*/
17 #ifndef __ICO_LOG_H__
18 #define __ICO_LOG_H__
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 #ifndef ICO_LOG_STDOUT
25 #define ICO_LOG_STDOUT      0
26                             /**!< Log output to stdout(=1) or file(=0) */
27 #endif /*ICO_APF_LOG_STDOUT*/
28
29 #define ICO_LOG_DIR         "/var/log/ico"
30                            /**!< Directory name of Log destination */
31
32 /* Maximum lines/files */
33 #define ICO_LOG_MAXLINES    20000
34                             /**!< Maximum output lines of log file  */
35 #define ICO_LOG_MAXFILES    6
36                             /**!< Maximum number of the log file    */
37
38 /* Log output level */
39 #define ICO_LOG_LVL_PRF     0x0200  /**!< Performance */
40 #define ICO_LOG_LVL_TRA     0x0100  /**!< Trace       */
41 #define ICO_LOG_LVL_DBG     0x0080  /**!< Debug write */
42 #define ICO_LOG_LVL_INF     0x0040  /**!< Information */
43 #define ICO_LOG_LVL_WRN     0x0010  /**!< Warning     */
44 #define ICO_LOG_LVL_CRI     0x0008  /**!< Critical    */
45 #define ICO_LOG_LVL_ERR     0x0004  /**!< Error       */
46
47 /* Log output flush */
48 #define ICO_LOG_FLUSH       0x4000  /**!< Log outout with log flush     */
49 #define ICO_LOG_NOFLUSH     0x2000  /**!< Log output without log flush  */
50
51 #define ICO_PRF(fmt,...)                        \
52 {                                               \
53     ico_log_print(ICO_LOG_LVL_PRF,              \
54                   "%s> " fmt " (%s,%s:%d)\n",   \
55                   ico_get_str_cur_time("PRF"),  \
56                   ##__VA_ARGS__,                \
57                   __func__,                     \
58                   __FILE__,                     \
59                   __LINE__);                    \
60 }
61
62 #define ICO_TRA(fmt,...)                        \
63 {                                               \
64     ico_log_print(ICO_LOG_LVL_TRA,              \
65                   "%s> " fmt " (%s,%s:%d)\n",   \
66                   ico_get_str_cur_time("TRA"),  \
67                   ##__VA_ARGS__,                \
68                   __func__,                     \
69                   __FILE__,                     \
70                   __LINE__);                    \
71 }
72
73 #define ICO_DBG(fmt,...)                        \
74 {                                               \
75     ico_log_print(ICO_LOG_LVL_DBG,              \
76                   "%s> " fmt " (%s,%s:%d)\n",   \
77                   ico_get_str_cur_time("DBG"),  \
78                   ##__VA_ARGS__,                \
79                   __func__,                     \
80                   __FILE__,                     \
81                   __LINE__);                    \
82 }
83
84 #define ICO_INF(fmt,...)                        \
85 {                                               \
86     ico_log_print(ICO_LOG_LVL_INF,              \
87                   "%s> " fmt " (%s,%s:%d)\n",   \
88                   ico_get_str_cur_time("INF"),  \
89                   ##__VA_ARGS__,                \
90                   __func__,                     \
91                   __FILE__,                     \
92                   __LINE__);                    \
93 }
94
95 #define ICO_WRN(fmt,...)                        \
96 {                                               \
97     ico_log_print(ICO_LOG_LVL_WRN,              \
98                   "%s> " fmt " (%s,%s:%d)\n",   \
99                   ico_get_str_cur_time("WRN"),  \
100                   ##__VA_ARGS__,                \
101                   __func__,                     \
102                   __FILE__,                     \
103                   __LINE__);                    \
104 }
105
106 #define ICO_CRI(fmt,...)                        \
107 {                                               \
108     ico_log_print(ICO_LOG_LVL_CRI,              \
109                   "%s> " fmt " (%s,%s:%d)\n",   \
110                   ico_get_str_cur_time("CRI"),  \
111                   ##__VA_ARGS__,                \
112                   __func__,                     \
113                   __FILE__,                     \
114                   __LINE__);                    \
115 }
116
117 #define ICO_ERR(fmt,...)                        \
118 {                                               \
119     ico_log_print(ICO_LOG_LVL_ERR,              \
120                   "%s> " fmt " (%s,%s:%d)\n",   \
121                   ico_get_str_cur_time("ERR"),  \
122                   ##__VA_ARGS__,                \
123                   __func__,                     \
124                   __FILE__,                     \
125                   __LINE__);                    \
126 }
127
128
129 void ico_log_print(int level, const char *fmt, ...);
130 void ico_log_open(const char *prog);
131 void ico_log_close(void);
132 void ico_log_flush(void);
133 char * ico_get_str_cur_time(const char *level);
134 void ico_log_set_level(int level);
135
136 #ifdef __cplusplus
137 }
138 #endif
139
140 #endif  // __ICO__LOG_H__
141 /* vim:set expandtab ts=4 sw=4: */