DumpLog.Log4CPP.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #pragma once
  2. #include <assert.h>
  3. #include "String.DString.hpp"
  4. //-----------------------------------------------------------------------------
  5. // DumpLog רÓÃÓÚ Dump, ´¿´â´Ó mLog ¸´ÖƶøÀ´
  6. //-----------------------------------------------------------------------------
  7. namespace DumpLog
  8. {
  9. extern Log4CPP::Logger * gLogger;
  10. inline void NewLine ()
  11. {
  12. if (! gLogger) return;
  13. gLogger->NewLine ();
  14. }
  15. inline eSTR::DString ErrorCodeToString (DWORD errorCode)
  16. {
  17. if (! gLogger) return eSTR::DString ();
  18. return gLogger->ErrorCodeToString (errorCode);
  19. }
  20. template <typename... Args>
  21. inline void Force (const char * fmt, Args && ... args)
  22. {
  23. if (! gLogger) return;
  24. gLogger->Force (fmt, std::forward <Args> (args)...);
  25. }
  26. template <typename... Args>
  27. inline void Log (const char * fmt, Args && ... args)
  28. {
  29. if (! gLogger) return;
  30. gLogger->Info (fmt, std::forward <Args> (args)...);
  31. }
  32. template <typename... Args>
  33. inline void Trace (const char * fmt, Args && ... args)
  34. {
  35. if (! gLogger) return;
  36. gLogger->Trace (fmt, std::forward <Args> (args)...);
  37. }
  38. template <typename... Args>
  39. inline void Debug (const char * fmt, Args && ... args)
  40. {
  41. if (! gLogger) return;
  42. gLogger->Debug (fmt, std::forward <Args> (args)...);
  43. }
  44. template <typename... Args>
  45. inline void Info (const char * fmt, Args && ... args)
  46. {
  47. if (! gLogger) return;
  48. gLogger->Info (fmt, std::forward <Args> (args)...);
  49. }
  50. template <typename... Args>
  51. inline void Notice (const char * fmt, Args && ... args)
  52. {
  53. if (! gLogger) return;
  54. gLogger->Notice (fmt, std::forward <Args> (args)...);
  55. }
  56. template <typename... Args>
  57. inline void Warn (const char * fmt, Args && ... args)
  58. {
  59. if (! gLogger) return;
  60. gLogger->Warn (fmt, std::forward <Args> (args)...);
  61. }
  62. template <typename... Args>
  63. inline void Warning (const char * fmt, Args && ... args)
  64. {
  65. if (! gLogger) return;
  66. gLogger->Warn (fmt, std::forward <Args> (args)...);
  67. }
  68. template <typename... Args>
  69. inline void Error (const char * fmt, Args && ... args)
  70. {
  71. if (! gLogger) return;
  72. gLogger->Error (fmt, std::forward <Args> (args)...);
  73. }
  74. template <typename... Args>
  75. inline void Fatal (const char * fmt, Args && ... args)
  76. {
  77. if (! gLogger) return;
  78. gLogger->Fatal (fmt, std::forward <Args> (args)...);
  79. }
  80. inline void Flush (const eSTR::DString& str)
  81. {
  82. if (! gLogger) return;
  83. gLogger->LogNoFormat (Log4CPP::enInfo, str, str.GetLength (), false);
  84. }
  85. inline void LogNoFormat (int Level, const eSTR::DString & str, bool bWithLayout = false)
  86. {
  87. if (! gLogger) return;
  88. gLogger->LogNoFormat (Level, str, str.GetLength (), bWithLayout);
  89. }
  90. inline void LogNoFormat (int Level, const char * buf, int len, bool bWithLayout = false)
  91. {
  92. if (! gLogger) return;
  93. gLogger->LogNoFormat (Level, buf, len, bWithLayout);
  94. }
  95. inline bool Decide (int Level = Log4CPP::enDetail)
  96. {
  97. if (! gLogger) return false;
  98. return (gLogger->Decide (Level));
  99. }
  100. inline void Close ()
  101. {
  102. if (! gLogger) return;
  103. gLogger->Close ();
  104. }
  105. };