12 #ifndef __KOME_CORE_LOG_FUNCTIONS_H__
13 #define __KOME_CORE_LOG_FUNCTIONS_H__
17 #define LOG_LEVEL_NONE 0
18 #define LOG_LEVEL_FATAL 1
19 #define LOG_LEVEL_ERROR 2
20 #define LOG_LEVEL_WARN 3
21 #define LOG_LEVEL_INFO 4
22 #define LOG_LEVEL_DEBUG 5
23 #define LOG_LEVEL_TRACE 6
25 #define MIN_LOG_LEVEL 0
26 #define MAX_LOG_LEVEL 6
30 #define OUTPUT_LOG( msg, level ) { \
31 if( level <= getloglevel() ) { \
32 outputlog( msg, level, __FILE__, __LINE__ ); \
36 #define LOG_FATAL_CODE( msg, code ) logfatalcode( code, msg.c_str(), __FILE__, __LINE__ )
37 #define LOG_ERROR_CODE( msg, code ) logerrorcode( code, msg.c_str(), __FILE__, __LINE__ )
38 #define LOG_WARN_CODE( msg, code ) logwarncode( code, msg.c_str(), __FILE__, __LINE__ )
39 #define LOG_INFO_CODE( msg, code ) loginfocode( code, msg.c_str(), __FILE__, __LINE__ )
40 #define LOG_DEBUG_CODE( msg, code ) logdebugcode( code, msg.c_str(), __FILE__, __LINE__ )
41 #define LOG_TRACE_CODE( msg, code ) logtracecode( code, msg.c_str(), __FILE__, __LINE__ )
43 #define OUTPUT_LOG( msg, level ) { \
44 if( level <= getloglevel() ) { \
45 outputlog( msg, level, NULL, -1 ); \
49 #define LOG_FATAL_CODE( msg, code ) logfatalcode( code, msg.c_str(), NULL, -1 )
50 #define LOG_ERROR_CODE( msg, code ) logerrorcode( code, msg.c_str(), NULL, -1 )
51 #define LOG_WARN_CODE( msg, code ) logwarncode( code, msg.c_str(), NULL, -1 )
52 #define LOG_INFO_CODE( msg, code ) loginfocode( code, msg.c_str(), NULL, -1 )
53 #define LOG_DEBUG_CODE( msg, code ) logdebugcode( code, msg.c_str(), NULL, -1 )
54 #define LOG_TRACE_CODE( msg, code ) logtracecode( code, msg.c_str(), NULL, -1 )
57 #define LOG_FATAL( msg ) OUTPUT_LOG( msg.c_str(), LOG_LEVEL_FATAL )
58 #define LOG_ERROR( msg ) OUTPUT_LOG( msg.c_str(), LOG_LEVEL_ERROR )
59 #define LOG_WARN( msg ) OUTPUT_LOG( msg.c_str(), LOG_LEVEL_WARN )
60 #define LOG_INFO( msg ) OUTPUT_LOG( msg.c_str(), LOG_LEVEL_INFO )
61 #define LOG_DEBUG( msg ) OUTPUT_LOG( msg.c_str(), LOG_LEVEL_DEBUG )
62 #define LOG_TRACE( msg ) OUTPUT_LOG( msg.c_str(), LOG_LEVEL_TRACE )
109 void outputlog(
const char* msg,
int level,
const char* file =
NULL,
int line = -1);
118 void logfatal(
const char* msg,
const char* file =
NULL,
int line = -1 );
128 void logfatalcode(
int code,
const char* msg,
const char* file =
NULL,
int line = -1 );
137 void logerror(
const char* msg,
const char* file =
NULL,
int line = -1 );
147 void logerrorcode(
int code,
const char* msg,
const char* file =
NULL,
int line = -1 );
156 void logwarn(
const char* msg,
const char* file =
NULL,
int line = -1 );
166 void logwarncode(
int code,
const char* msg,
const char* file =
NULL,
int line = -1 );
175 void loginfo(
const char* msg,
const char* file =
NULL,
int line = -1 );
185 void loginfocode(
int code,
const char* msg,
const char* file =
NULL,
int line = -1 );
194 void logdebug(
const char* msg,
const char* file =
NULL,
int line = -1 );
204 void logdebugcode(
int code,
const char* msg,
const char* file =
NULL,
int line = -1 );
213 void logtrace(
const char* msg,
const char* file =
NULL,
int line = -1 );
223 void logtracecode(
int code,
const char* msg,
const char* file =
NULL,
int line = -1 );
255 #endif // __KOME_CORE_LOG_FUNCTIONS_H__
void loginfo(const char *msg, const char *file=NULL, int line=-1)
output information log
void outputlog(const char *msg, int level, const char *file=NULL, int line=-1)
output log
void logfatal(const char *msg, const char *file=NULL, int line=-1)
output fatal log
void setoutputlogfunction(void(*outputLogFun)(const char *, int))
set output log function
void logwarn(const char *msg, const char *file=NULL, int line=-1)
output warning log
void logtrace(const char *msg, const char *file=NULL, int line=-1)
output trace log
void logerror(const char *msg, const char *file=NULL, int line=-1)
output error log
const char * getlasterrormessage()
get last error message
void logflush()
flushes logs to be stored in the list
void logfatalcode(int code, const char *msg, const char *file=NULL, int line=-1)
output fatal log and set error code
void logtracecode(int code, const char *msg, const char *file=NULL, int line=-1)
output trace log and set error code
void logerrorcode(int code, const char *msg, const char *file=NULL, int line=-1)
output error log and set error code
void logdebugcode(int code, const char *msg, const char *file=NULL, int line=-1)
output debug log and set error code
void logdebug(const char *msg, const char *file=NULL, int line=-1)
output debug log
void setloglevel(int level)
set log level
void logwarncode(int code, const char *msg, const char *file=NULL, int line=-1)
output warning log and set error code
int getloglistsize()
gets log list size
int getlasterror()
get last error code
void setloglistsize(const int size)
sets log list size
int getloglevel()
get log level
void loginfocode(int code, const char *msg, const char *file=NULL, int line=-1)
output information log and set error code
void seterrorcode(int code, const char *msg)
set error code