diff --git a/qse/include/qse/si/App.hpp b/qse/include/qse/si/App.hpp index 8fc09a7f..aa2b0efe 100644 --- a/qse/include/qse/si/App.hpp +++ b/qse/include/qse/si/App.hpp @@ -40,17 +40,17 @@ QSE_BEGIN_NAMESPACE(QSE) ///////////////////////////////// -#define QSE_APP_LOG_ENABLED(app, mask) (((app)->getLogMask() & mask) == mask) -#define QSE_APP_LOG0(app, mask, fmt) do { if (QSE_APP_LOG_ENABLED(app, mask)) app->logfmt(mask, fmt); } while(0) -#define QSE_APP_LOG1(app, mask, fmt, a1) do { if (QSE_APP_LOG_ENABLED(app, mask)) app->logfmt(mask, fmt, a1); } while(0) -#define QSE_APP_LOG2(app, mask, fmt, a1, a2) do { if (QSE_APP_LOG_ENABLED(app, mask)) app->logfmt(mask, fmt, a1, a2); } while(0) -#define QSE_APP_LOG3(app, mask, fmt, a1, a2, a3) do { if (QSE_APP_LOG_ENABLED(app, mask)) app->logfmt(mask, fmt, a1, a2, a3); } while(0) -#define QSE_APP_LOG4(app, mask, fmt, a1, a2, a3, a4) do { if (QSE_APP_LOG_ENABLED(app, mask)) app->logfmt(mask, fmt, a1, a2, a3, a4); } while(0) -#define QSE_APP_LOG5(app, mask, fmt, a1, a2, a3, a4, a5) do { if (QSE_APP_LOG_ENABLED(app, mask)) app->logfmt(mask, fmt, a1, a2, a3, a4, a5); } while(0) -#define QSE_APP_LOG6(app, mask, fmt, a1, a2, a3, a4, a5, a6) do { if (QSE_APP_LOG_ENABLED(app, mask)) app->logfmt(mask, fmt, a1, a2, a3, a4, a5, a6); } while(0) -#define QSE_APP_LOG7(app, mask, fmt, a1, a2, a3, a4, a5, a6, a7) do { if (QSE_APP_LOG_ENABLED(app, mask)) app->logfmt(mask, fmt, a1, a2, a3, a4, a5, a6, a7); } while(0) -#define QSE_APP_LOG8(app, mask, fmt, a1, a2, a3, a4, a5, a6, a7, a8) do { if (QSE_APP_LOG_ENABLED(app, mask)) app->logfmt(mask, fmt, a1, a2, a3, a4, a5, a6, a7, a8); } while(0) -#define QSE_APP_LOG9(app, mask, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9) do { if (QSE_APP_LOG_ENABLED(app, mask)) app->logfmt(mask, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9); } while(0) +#define QSE_APP_LOG_ENABLED(app, mask) (((app)->getLogMask() & (mask)) == (mask)) +#define QSE_APP_LOG0(app, mask, fmt) do { if (QSE_APP_LOG_ENABLED(app, (mask))) app->logfmt((mask), fmt); } while(0) +#define QSE_APP_LOG1(app, mask, fmt, a1) do { if (QSE_APP_LOG_ENABLED(app, (mask))) app->logfmt((mask), fmt, a1); } while(0) +#define QSE_APP_LOG2(app, mask, fmt, a1, a2) do { if (QSE_APP_LOG_ENABLED(app, (mask))) app->logfmt((mask), fmt, a1, a2); } while(0) +#define QSE_APP_LOG3(app, mask, fmt, a1, a2, a3) do { if (QSE_APP_LOG_ENABLED(app, (mask))) app->logfmt((mask), fmt, a1, a2, a3); } while(0) +#define QSE_APP_LOG4(app, mask, fmt, a1, a2, a3, a4) do { if (QSE_APP_LOG_ENABLED(app, (mask))) app->logfmt((mask), fmt, a1, a2, a3, a4); } while(0) +#define QSE_APP_LOG5(app, mask, fmt, a1, a2, a3, a4, a5) do { if (QSE_APP_LOG_ENABLED(app, (mask))) app->logfmt((mask), fmt, a1, a2, a3, a4, a5); } while(0) +#define QSE_APP_LOG6(app, mask, fmt, a1, a2, a3, a4, a5, a6) do { if (QSE_APP_LOG_ENABLED(app, (mask))) app->logfmt((mask), fmt, a1, a2, a3, a4, a5, a6); } while(0) +#define QSE_APP_LOG7(app, mask, fmt, a1, a2, a3, a4, a5, a6, a7) do { if (QSE_APP_LOG_ENABLED(app, (mask))) app->logfmt((mask), fmt, a1, a2, a3, a4, a5, a6, a7); } while(0) +#define QSE_APP_LOG8(app, mask, fmt, a1, a2, a3, a4, a5, a6, a7, a8) do { if (QSE_APP_LOG_ENABLED(app, (mask))) app->logfmt((mask), fmt, a1, a2, a3, a4, a5, a6, a7, a8); } while(0) +#define QSE_APP_LOG9(app, mask, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9) do { if (QSE_APP_LOG_ENABLED(app, (mask))) app->logfmt((mask), fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9); } while(0) class App: public Uncopyable, public Types, public Mmged { @@ -193,11 +193,8 @@ public: void logfmtv (int mask, const qse_char_t* fmt, va_list ap); protected: - virtual void log_write (int mask, const qse_char_t* msg, qse_size_t len) - { - // do nothing - // subclasses should override this if needed. - } + // subclasses may override this if the defaulg logging output is not desired. + virtual void log_write (int mask, const qse_char_t* msg, qse_size_t len); private: App* _prev_app; diff --git a/qse/lib/si/App.cpp b/qse/lib/si/App.cpp index c1754dd0..62a6a289 100644 --- a/qse/lib/si/App.cpp +++ b/qse/lib/si/App.cpp @@ -549,13 +549,13 @@ int App::put_char_to_log_buf (qse_char_t c, void* ctx) static int wcs_to_mbs (const qse_wchar_t* wcs, qse_size_t* wcslen, qse_mchar_t* mbs, qse_size_t* mbslen, void* ctx) { App* app = (App*)ctx; - return qse_wcsntombsnwithcmgr (wcs, wcslen, mbs, mbslen, app->getCmgr()); + return qse_wcsntombsnwithcmgr(wcs, wcslen, mbs, mbslen, app->getCmgr()); } static int mbs_to_wcs (const qse_mchar_t* mbs, qse_size_t* mbslen, qse_wchar_t* wcs, qse_size_t* wcslen, void* ctx) { App* app = (App*)ctx; - return qse_mbsntowcsnwithcmgr (mbs, mbslen, wcs, wcslen, app->getCmgr()); + return qse_mbsntowcsnwithcmgr(mbs, mbslen, wcs, wcslen, app->getCmgr()); } void App::logfmtv (int mask, const qse_char_t* fmt, va_list ap) @@ -591,6 +591,12 @@ void App::logfmtv (int mask, const qse_char_t* fmt, va_list ap) /*if (this->threaded)*/ this->_log.mtx.unlock (); } +// default log message output implementation +void App::log_write (int mask, const qse_char_t* msg, qse_size_t len) +{ +} + + ///////////////////////////////// QSE_END_NAMESPACE(QSE) /////////////////////////////////