diff --git a/cwLog.cpp b/cwLog.cpp index 29fbe76..b697ad5 100644 --- a/cwLog.cpp +++ b/cwLog.cpp @@ -112,6 +112,21 @@ unsigned cw::log::level( handle_t h ) return p->level; } +void cw::log::setOutputCb( handle_t h, logOutputCbFunc_t outFunc, void* outCbArg ) +{ + log_t* p = _handleToPtr(h); + p->outCbFunc = outFunc; + p->outCbArg = outCbArg; +} + +void cw::log::setFormatCb( handle_t h, logFormatCbFunc_t fmtFunc, void* fmtCbArg ) +{ + log_t* p = _handleToPtr(h); + p->fmtCbFunc = fmtFunc; + p->fmtCbArg = fmtCbArg; + +} + const char* cw::log::levelToLabel( unsigned level ) { diff --git a/cwLog.h b/cwLog.h index ae3bdd5..623d0a2 100644 --- a/cwLog.h +++ b/cwLog.h @@ -31,6 +31,9 @@ namespace cw void setLevel( handle_t h, unsigned level ); unsigned level( handle_t h ); + void setOutputCb( handle_t h, logOutputCbFunc_t outFunc, void* outCbArg ); + void setFormatCb( handle_t h, logFormatCbFunc_t fmtFunc, void* fmtCbArg ); + const char* levelToLabel( unsigned level ); void defaultOutput( void* arg, unsigned level, const char* text ); @@ -113,11 +116,11 @@ namespace cw // By defining cwLOG_MODULE prior to cwLog.h in a given module these logging lines will be enabled. #ifdef cwLOG_MODULE -#define cwLogVModRC(rc,fmt, vl) cwLogVInfoH( cw::log::globalhandle(), (rc), (fmt), (vl) ) -#define cwLogModRC( rc,fmt,...) cwLogInfoH( cw::log::globalHandle(), (rc), (fmt), ##__VA_ARGS__ ) +#define cwLogVModRC(rc,fmt, vl) cw::log::msg( cw::log::globalHandle(), cw::log::kInfo_LogLevel, __FUNCTION__, __FILE__, __LINE__, 0, (rc), (fmt), (vl) ) +#define cwLogModRC( rc,fmt,...) cw::log::msg( cw::log::globalHandle(), cw::log::kInfo_LogLevel, __FUNCTION__, __FILE__, __LINE__, 0, (rc), (fmt), ##__VA_ARGS__ ) -#define cwLogVMod(fmt, vl) cwLogVInfoH( cw::log::globalHandle(), cw::kOkRC, (fmt), (vl) ) -#define cwLogMod( fmt,...) cwLogInfoH( cw::log::globalHandle(), cw::kOkRC, (fmt), ##__VA_ARGS__ ) +#define cwLogVMod(fmt, vl) cw::log::msg( cw::log::globalHandle(), cw::log::kInfo_LogLevel, __FUNCTION__, __FILE__, __LINE__, 0, cw::kOkRC, (fmt), (vl) ) +#define cwLogMod( fmt,...) cw::log::msg( cw::log::globalHandle(), cw::log::kInfo_LogLevel, __FUNCTION__, __FILE__, __LINE__, 0, cw::kOkRC, (fmt), ##__VA_ARGS__ ) #else