2 * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
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
11 * @brief Application Framework debug log function
16 #ifndef __CICO_LOG_H__
17 #define __CICO_LOG_H__
25 #include <sys/types.h>
28 #ifndef ICO_LOG_STDOUT
29 #define ICO_LOG_STDOUT 0 /* Log output to stdout(=1) or file(=0) */
30 #endif /*ICO_APF_LOG_STDOUT*/
32 #define ICO_LOG_DIR "/var/log/ico"
33 /* Directory name of Log destination */
35 /* Maximum lines/files */
36 #define ICO_LOG_MAXLINES 10000 /* Maximum output lines of one log file */
37 #define ICO_LOG_MAXFILES 6 /* Maximum number of the log file */
39 /* Log output level */
40 #define ICO_LOG_DEBUG 128 /* Debug write */
41 #define ICO_LOG_INFO 64 /* Information */
42 #define ICO_LOG_WARNING 16 /* Warning */
43 #define ICO_LOG_CRITICAL 8 /* Critical */
44 #define ICO_LOG_ERROR 4 /* Error */
46 /* Log output flush */
47 #define ICO_LOG_FLUSH 0x4000 /* Log outout with log flush */
48 #define ICO_LOG_NOFLUSH 0x2000 /* Log output without log flush */
50 #define ICO_TRA(fmt,...) \
52 CicoLog::getInstance()->printLog(ICO_LOG_DEBUG, \
53 "%s> " fmt " (%s,%s:%d)\n", \
54 CicoLog::getStrCurTime("DBG"), \
61 #define ICO_DBG(fmt,...) \
63 CicoLog::getInstance()->printLog(ICO_LOG_DEBUG, \
64 "%s> " fmt " (%s,%s:%d)\n", \
65 CicoLog::getStrCurTime("DBG"), \
72 #define ICO_INF(fmt,...) \
74 CicoLog::getInstance()->printLog(ICO_LOG_INFO, \
75 "%s> " fmt " (%s,%s:%d)\n", \
76 CicoLog::getStrCurTime("INF"), \
83 #define ICO_WRN(fmt,...) \
85 CicoLog::getInstance()->printLog(ICO_LOG_WARNING, \
86 "%s> " fmt " (%s,%s:%d)\n", \
87 CicoLog::getStrCurTime("WRN"), \
94 #define ICO_CRI(fmt,...) \
96 CicoLog::getInstance()->printLog(ICO_LOG_CRITICAL, \
97 "%s> " fmt " (%s,%s:%d)\n", \
98 CicoLog::getStrCurTime("CRI"), \
105 #define ICO_ERR(fmt,...) \
107 CicoLog::getInstance()->printLog(ICO_LOG_ERROR, \
108 "%s> " fmt " (%s,%s:%d)\n", \
109 CicoLog::getStrCurTime("ERR"), \
123 static CicoLog* getInstance(void);
125 void printLog(int loglevel, const char *fmt, ...);
127 void openLog(const char *prog);
133 void setLogLevel(const int loglevel);
135 static char * getStrCurTime(const char *level);
138 static CicoLog* ms_myInstance; //!< CicoLog Object
139 static int m_sTimeZone; //!< local time difference(sec)
140 int m_logLevel; //!< output level debug log
141 bool m_flushMode; //!< flush mode flag
142 bool m_initialized; //!< initialized flag
143 FILE *m_sDbgFd; //!< file descriptor of output debug log
144 int m_sDbgLines; //!< output lines
145 char m_sDbgProg[32]; //!< name of output source module
147 #endif // __CICO_LOG_H__
148 // vim:set expandtab ts=4 sw=4: