Mass++ Common Libraries v2.7.5
 All Classes Namespaces Files Functions Variables Enumerations Macros
LogFunctions.h
Go to the documentation of this file.
1 
12 #ifndef __KOME_CORE_LOG_FUNCTIONS_H__
13 #define __KOME_CORE_LOG_FUNCTIONS_H__
14 
15 
16 // define
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
24 
25 #define MIN_LOG_LEVEL 0
26 #define MAX_LOG_LEVEL 6
27 
28 // macros
29 #ifdef _DEBUG
30  #define OUTPUT_LOG( msg, level ) { \
31  if( level <= getloglevel() ) { \
32  outputlog( msg, level, __FILE__, __LINE__ ); \
33  } \
34  }
35 
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__ )
42 #else
43  #define OUTPUT_LOG( msg, level ) { \
44  if( level <= getloglevel() ) { \
45  outputlog( msg, level, NULL, -1 ); \
46  } \
47  }
48 
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 )
55 #endif // _DEBUG
56 
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 )
63 
64 
70 void setloglevel( int level );
71 
77 int getloglevel();
78 
84 int getlasterror();
85 
91 const char* getlasterrormessage();
92 
99 void seterrorcode( int code, const char* msg );
100 
109 void outputlog( const char* msg, int level, const char* file = NULL, int line = -1);
110 
118 void logfatal( const char* msg, const char* file = NULL, int line = -1 );
119 
128 void logfatalcode( int code, const char* msg, const char* file = NULL, int line = -1 );
129 
137 void logerror( const char* msg, const char* file = NULL, int line = -1 );
138 
147 void logerrorcode( int code, const char* msg, const char* file = NULL, int line = -1 );
148 
156 void logwarn( const char* msg, const char* file = NULL, int line = -1 );
157 
166 void logwarncode( int code, const char* msg, const char* file = NULL, int line = -1 );
167 
175 void loginfo( const char* msg, const char* file = NULL, int line = -1 );
176 
185 void loginfocode( int code, const char* msg, const char* file = NULL, int line = -1 );
186 
194 void logdebug( const char* msg, const char* file = NULL, int line = -1 );
195 
204 void logdebugcode( int code, const char* msg, const char* file = NULL, int line = -1 );
205 
213 void logtrace( const char* msg, const char* file = NULL, int line = -1 );
214 
223 void logtracecode( int code, const char* msg, const char* file = NULL, int line = -1 );
224 
225 
231  void setloglistsize( const int size );
232 
238 int getloglistsize();
239 
244 void logflush();
245 
252 void setoutputlogfunction( void (*outputLogFun)( const char*, int ) );
253 
254 
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
#define NULL
Definition: CoreMacros.h:18
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