00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _rlog_incl_
00021 #define _rlog_incl_
00022
00023 #define CONCAT2(A,B) A##B
00024 #define CONCAT(A,B) CONCAT2(A,B)
00025 #define STR(X) #X
00026
00027 #include <rlog/common.h>
00028
00034
00035 #define CURRENT_RLOG_VERSION 20040503
00036 extern "C" int RLogVersion();
00037
00038 namespace rlog
00039 {
00040
00041 class RLogChannel;
00042 class RLogPublisher;
00043 class RLogNode;
00044
00048 enum LogLevel
00049 {
00050 Log_Undef =0,
00051 Log_Critical,
00052 Log_Error,
00053 Log_Warning,
00054 Log_Notice,
00055 Log_Info,
00056 Log_Debug
00057 };
00058
00069 void RLOG_DECL RLogInit(int &argc, char **argv);
00070
00071
00072
00073 RLOG_DECL RLogChannel *GetComponentChannel(const char *component,
00074 const char *path,
00075 LogLevel level = Log_Undef);
00076
00077
00078 RLOG_DECL RLogChannel *GetGlobalChannel( const char *path,
00079 LogLevel level = Log_Undef);
00080
00124 #define DEF_CHANNEL(path,level) RLOG_CHANNEL_IMPL(RLOG_COMPONENT, path, level)
00125 #define RLOG_CHANNEL(path) RLOG_CHANNEL_IMPL(RLOG_COMPONENT, path, rlog::Log_Undef)
00126 #define RLOG_CHANNEL_IMPL(COMPONENT,path,level) \
00127 rlog::GetComponentChannel(STR(COMPONENT),path,level)
00128
00129
00130
00131
00132
00133
00134
00135
00136 extern RLOG_DECL RLogChannel *_RLDebugChannel;
00137 extern RLOG_DECL RLogChannel *_RLInfoChannel;
00138 extern RLOG_DECL RLogChannel *_RLWarningChannel;
00139 extern RLOG_DECL RLogChannel *_RLErrorChannel;
00140
00153 struct PublishLoc
00154 {
00155
00156
00157
00158
00160 void (*publish)(PublishLoc *, RLogChannel *, const char *format, ... )
00161 PRINTF_FP(3,4);
00162 RLogNode *pub;
00163 const char *component;
00164 const char *fileName;
00165 const char *functionName;
00166 int lineNum;
00167 RLogChannel *channel;
00168 };
00169
00176 void RLOG_DECL RLog_Register(PublishLoc *loc, RLogChannel *,
00177 const char *format, ... ) PRINTF(3,4);
00178
00184 void RLOG_DECL rAssertFailed( const char *component, const char *file,
00185 const char *function, int line,
00186 const char *conditionStr );
00187
00188
00189
00190 #if !HAVE_PRINTF_FP && HAVE_PRINTF_ATTR
00191 void __checkArgs(int, const char *, ... ) PRINTF(2,3);
00192
00193 inline void __checkArgs(int, const char *, ...)
00194 { }
00195 #endif
00196 }
00197
00198 #if C99_VARIADAC_MACROS
00199 #include <rlog/rlog-c99.h>
00200 #elif PREC99_VARIADAC_MACROS
00201 #include <rlog/rlog-prec99.h>
00202 #else
00203 #include <rlog/rlog-novariadic.h>
00204 #endif
00205
00206
00207 #define _rAssertFailed(COMPONENT, COND) \
00208 rlog::rAssertFailed(STR(COMPONENT),__FILE__,__FUNCTION__,__LINE__, COND)
00209
00220 #define rAssert( cond ) \
00221 do { \
00222 if( unlikely((cond) == false) ) \
00223 { rError( "Assert failed: " STR(cond) ); \
00224 _rAssertFailed(RLOG_COMPONENT, STR(cond)); \
00225 } \
00226 } while(0)
00227
00235 #define rAssertSilent( cond ) \
00236 do { \
00237 if( unlikely((cond) == false) ) \
00238 { _rAssertFailed(RLOG_COMPONENT, STR(cond)); } \
00239 } while(0)
00240
00241
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255 #define RLOG_NO_COPY(CNAME) \
00256 private: \
00257 CNAME(const CNAME&); \
00258 CNAME & operator = (const CNAME &)
00259
00260
00261 #endif // rlog.h
00262