mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-17 00:35:55 +01:00
55500acdf9
git-subtree-dir: lib/loggerpro git-subtree-split: d1e0db6e93724e5fd825f0a8c02151d60450f98f
60 lines
1002 B
ObjectPascal
60 lines
1002 B
ObjectPascal
unit LoggerProConfig;
|
|
|
|
interface
|
|
|
|
uses
|
|
LoggerPro;
|
|
|
|
function Log: ILogWriter;
|
|
|
|
implementation
|
|
|
|
uses
|
|
LoggerPro.ConsoleAppender, System.SysUtils;
|
|
|
|
type
|
|
TMyCustomAppender = class(TLoggerProAppenderBase)
|
|
public
|
|
procedure Setup; override;
|
|
procedure TearDown; override;
|
|
procedure WriteLog(const aLogItem: TLogItem); override;
|
|
end;
|
|
|
|
var
|
|
_Log: ILogWriter;
|
|
|
|
function Log: ILogWriter;
|
|
begin
|
|
Result := _Log;
|
|
end;
|
|
|
|
{ TMyCustomAppender }
|
|
procedure TMyCustomAppender.Setup;
|
|
begin
|
|
//
|
|
end;
|
|
|
|
procedure TMyCustomAppender.TearDown;
|
|
begin
|
|
//
|
|
end;
|
|
|
|
procedure TMyCustomAppender.WriteLog(const aLogItem: TLogItem);
|
|
begin
|
|
// uncomment this to see what happend if an appender raise an exception
|
|
|
|
// raise Exception.Create('Kill LoggerPro');
|
|
|
|
// uncomment this to see what happend if an appender is slow
|
|
Sleep(2000);
|
|
WriteLn('[THE BAD APPENDER] ' + aLogItem.LogMessage);
|
|
end;
|
|
|
|
initialization
|
|
|
|
_Log := BuildLogWriter([
|
|
TLoggerProConsoleAppender.Create,
|
|
TMyCustomAppender.Create])
|
|
|
|
end.
|