HttpServerService.Logger.pas 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. unit HttpServerService.Logger;
  2. interface
  3. uses
  4. System.SysUtils,
  5. Quick.Logger.Intf;
  6. type
  7. TQuickLogger = class(TInterfacedObject,ILogger)
  8. public
  9. procedure Init;
  10. procedure Info(const aMsg : string); overload;
  11. procedure Info(const aMsg : string; aValues : array of const); overload;
  12. procedure Succ(const aMsg : string); overload;
  13. procedure Succ(const aMsg : string; aParams : array of const); overload;
  14. procedure Done(const aMsg : string); overload;
  15. procedure Done(const aMsg : string; aValues : array of const); overload;
  16. procedure Warn(const aMsg : string); overload;
  17. procedure Warn(const aMsg : string; aValues : array of const); overload;
  18. procedure Error(const aMsg : string); overload;
  19. procedure Error(const aMsg : string; aValues : array of const); overload;
  20. procedure Critical(const aMsg : string); overload;
  21. procedure Critical(const aMsg : string; aValues : array of const); overload;
  22. procedure Trace(const aMsg : string); overload;
  23. procedure Trace(const aMsg : string; aValues : array of const); overload;
  24. procedure Debug(const aMsg : string); overload;
  25. procedure Debug(const aMsg : string; aValues : array of const); overload;
  26. procedure &Except(const aMsg : string; aValues : array of const); overload;
  27. procedure &Except(const aMsg, aException, aStackTrace : string); overload;
  28. procedure &Except(const aMsg : string; aValues: array of const; const aException, aStackTrace: string); overload;
  29. end;
  30. implementation
  31. { TQuickLogger }
  32. uses
  33. Quick.Console,
  34. Quick.Commons;
  35. procedure TQuickLogger.Init;
  36. begin
  37. end;
  38. procedure TQuickLogger.Info(const aMsg: string);
  39. begin
  40. cout(aMsg, etInfo);
  41. end;
  42. procedure TQuickLogger.Info(const aMsg: string; aValues: array of const);
  43. begin
  44. cout(aMsg, aValues, etInfo);
  45. end;
  46. procedure TQuickLogger.Succ(const aMsg: string);
  47. begin
  48. cout(aMsg, etSuccess);
  49. end;
  50. procedure TQuickLogger.Succ(const aMsg: string; aParams: array of const);
  51. begin
  52. cout(aMsg,aParams, etSuccess);
  53. end;
  54. procedure TQuickLogger.Done(const aMsg: string);
  55. begin
  56. cout(aMsg, ccGreen);
  57. end;
  58. procedure TQuickLogger.Done(const aMsg: string; aValues: array of const);
  59. begin
  60. cout(format(aMsg, aValues), ccGreen);
  61. end;
  62. procedure TQuickLogger.Warn(const aMsg: string);
  63. begin
  64. cout(aMsg, etWarning);
  65. end;
  66. procedure TQuickLogger.Warn(const aMsg: string; aValues: array of const);
  67. begin
  68. cout(aMsg, aValues, etWarning);
  69. end;
  70. procedure TQuickLogger.Error(const aMsg: string);
  71. begin
  72. cout(aMsg, etError);
  73. end;
  74. procedure TQuickLogger.Error(const aMsg: string; aValues: array of const);
  75. begin
  76. cout(aMsg, aValues, etError);
  77. end;
  78. procedure TQuickLogger.Critical(const aMsg: string);
  79. begin
  80. cout(aMsg, ccRed);
  81. end;
  82. procedure TQuickLogger.Critical(const aMsg: string; aValues: array of const);
  83. begin
  84. cout(format(aMsg, aValues), ccRed);
  85. end;
  86. procedure TQuickLogger.Trace(const aMsg: string);
  87. begin
  88. cout(aMsg, etTrace);
  89. end;
  90. procedure TQuickLogger.Trace(const aMsg: string; aValues: array of const);
  91. begin
  92. cout(aMsg, aValues, etTrace);
  93. end;
  94. procedure TQuickLogger.Debug(const aMsg: string);
  95. begin
  96. cout(aMsg, etDebug);
  97. end;
  98. procedure TQuickLogger.Debug(const aMsg: string; aValues: array of const);
  99. begin
  100. cout(aMsg, aValues, etDebug);
  101. end;
  102. procedure TQuickLogger.&Except(const aMsg: string; aValues: array of const);
  103. begin
  104. cout('Exception: '+ aMsg, aValues, etError);
  105. end;
  106. procedure TQuickLogger.&Except(const aMsg: string; aValues: array of const; const aException, aStackTrace: string);
  107. begin
  108. cout('Exception: ' + aMsg + ' ('+aException+' : '+aStackTrace+')', aValues, etError);
  109. end;
  110. procedure TQuickLogger.&Except(const aMsg, aException, aStackTrace: string);
  111. begin
  112. cout('Exception: ' + aMsg + ' ('+aException+' : '+aStackTrace+')', etError);
  113. end;
  114. end.