123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- #pragma once
- #include <assert.h>
- #include "String.DString.hpp"
- //-----------------------------------------------------------------------------
- // tLog 是对 gLogger 的简单封装
- // tLog 可以理解为 tmpLog
- // 某些组件需要写到临时 Logger 中, 可以包含这个 hpp
- // 纯粹从 mLog 复制而来
- //-----------------------------------------------------------------------------
- namespace tLog
- {
- extern Log4CPP::Logger * gLogger;
- inline void NewLine ()
- {
- if (! gLogger) return;
- gLogger->NewLine ();
- }
- inline eSTR::DString ErrorCodeToString (DWORD errorCode)
- {
- if (! gLogger) return eSTR::DString ();
- return gLogger->ErrorCodeToString (errorCode);
- }
- template <typename... Args>
- inline void Force (const char* fmt, Args && ... args)
- {
- if (! gLogger) return;
- gLogger->Force (fmt, std::forward <Args> (args)...);
- }
- template <typename... Args>
- inline void Log (const char* fmt, Args && ... args)
- {
- if (! gLogger) return;
- gLogger->Info (fmt, std::forward <Args> (args)...);
- }
- template <typename... Args>
- inline void Trace (const char* fmt, Args && ... args)
- {
- if (! gLogger) return;
- gLogger->Trace (fmt, std::forward <Args> (args)...);
- }
- template <typename... Args>
- inline void Debug (const char* fmt, Args && ... args)
- {
- if (! gLogger) return;
- gLogger->Debug (fmt, std::forward <Args> (args)...);
- }
- template <typename... Args>
- inline void Info (const char* fmt, Args && ... args)
- {
- if (! gLogger) return;
- gLogger->Info (fmt, std::forward <Args> (args)...);
- }
- template <typename... Args>
- inline void Notice (const char* fmt, Args && ... args)
- {
- if (! gLogger) return;
- gLogger->Notice (fmt, std::forward <Args> (args)...);
- }
- template <typename... Args>
- inline void Warn (const char* fmt, Args && ... args)
- {
- if (! gLogger) return;
- gLogger->Warn (fmt, std::forward <Args> (args)...);
- }
- template <typename... Args>
- inline void Warning (const char* fmt, Args && ... args)
- {
- if (! gLogger) return;
- gLogger->Warn (fmt, std::forward <Args> (args)...);
- }
- template <typename... Args>
- inline void Error (const char* fmt, Args && ... args)
- {
- if (! gLogger) return;
- gLogger->Error (fmt, std::forward <Args> (args)...);
- }
- template <typename... Args>
- inline void Fatal (const char* fmt, Args && ... args)
- {
- if (! gLogger) return;
- gLogger->Fatal (fmt, std::forward <Args> (args)...);
- }
- inline void Flush (const eSTR::DStringView & str)
- {
- if (! gLogger) return;
- gLogger->LogNoFormat (Log4CPP::enInfo, str, str.GetLength (), false);
- }
- inline void Flush (const eSTR::DString & str)
- {
- if (! gLogger) return;
- gLogger->LogNoFormat (Log4CPP::enInfo, str, str.GetLength (), false);
- }
- inline void Flush (const char * str, int len)
- {
- if (! gLogger) return;
- gLogger->LogNoFormat (Log4CPP::enInfo, str, len, false);
- }
- inline void LogNoFormat (int Level, const eSTR::DString & str, bool bWithLayout = false)
- {
- if (! gLogger) return;
- gLogger->LogNoFormat (Level, str, str.GetLength (), bWithLayout);
- }
- inline void LogNoFormat (int Level, const char* buf, int len, bool bWithLayout = false)
- {
- if (! gLogger) return;
- gLogger->LogNoFormat (Level, buf, len, bWithLayout);
- }
- inline bool Decide (int Level)
- {
- if (! gLogger) return false;
- return (gLogger->Decide (Level));
- }
- inline void Close ()
- {
- if (! gLogger) return;
- gLogger->Close ();
- }
- };
|