From 55279360242e3007d60c552668c4d16dd204db12 Mon Sep 17 00:00:00 2001 From: kevin Date: Thu, 9 May 2024 21:54:39 -0400 Subject: [PATCH] cwLog : Added outputCbArg(),outputCb(),formatCbArg(),formatCb(). cwLogPrint() now prints irregardless of the current level. --- cwLog.cpp | 27 +++++++++++++++++++++++++-- cwLog.h | 6 ++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/cwLog.cpp b/cwLog.cpp index 3eb8297..7fa533c 100644 --- a/cwLog.cpp +++ b/cwLog.cpp @@ -112,7 +112,7 @@ cw::rc_t cw::log::msg( handle_t h, unsigned level, const char* function, const c cw::rc_t cw::log::msg( handle_t h, unsigned level, const char* function, const char* filename, unsigned line, int systemErrorCode, rc_t returnCode, const char* fmt, ... ) { rc_t rc = returnCode; - if( level >= _handleToPtr(h)->level ) + if( level >= _handleToPtr(h)->level || level == kPrint_LogLevel ) { va_list vl; va_start(vl,fmt); @@ -146,6 +146,29 @@ unsigned cw::log::flags( handle_t h ) return p->flags; } +void* cw::log::outputCbArg( handle_t h ) +{ + log_t* p = _handleToPtr(h); + return p->outCbArg; +} + +cw::log::logOutputCbFunc_t cw::log::outputCb( handle_t h ) +{ + log_t* p = _handleToPtr(h); + return p->outCbFunc; +} + +void* cw::log::formatCbArg( handle_t h ) +{ + log_t* p = _handleToPtr(h); + return p->fmtCbArg; +} + +cw::log::logFormatCbFunc_t cw::log::formatCb( handle_t h ) +{ + log_t* p = _handleToPtr(h); + return p->fmtCbFunc; +} void cw::log::setOutputCb( handle_t h, logOutputCbFunc_t outFunc, void* outCbArg ) { @@ -214,7 +237,7 @@ void cw::log::defaultFormatter( void* cbArg, logOutputCbFunc_t outFunc, void* ou // don't print the function,file,line when this is an 'info' msg. - if( level == kInfo_LogLevel ) + if( level == kInfo_LogLevel || level == kPrint_LogLevel ) { loStr = ""; syStr = ""; diff --git a/cwLog.h b/cwLog.h index 708a174..5ccf3a0 100644 --- a/cwLog.h +++ b/cwLog.h @@ -39,6 +39,12 @@ namespace cw void setLevel( handle_t h, unsigned level ); unsigned level( handle_t h ); + void* outputCbArg( handle_t h ); + logOutputCbFunc_t outputCb( handle_t h ); + + void* formatCbArg( handle_t h ); + logFormatCbFunc_t formatCb( handle_t h ); + void setOutputCb( handle_t h, logOutputCbFunc_t outFunc, void* outCbArg ); void setFormatCb( handle_t h, logFormatCbFunc_t fmtFunc, void* fmtCbArg );