delphimvcframework/LoggerPro.SimpleConsoleAppender.pas
Daniele Teti 55500acdf9 Squashed 'lib/loggerpro/' content from commit d1e0db6e
git-subtree-dir: lib/loggerpro
git-subtree-split: d1e0db6e93724e5fd825f0a8c02151d60450f98f
2023-02-27 12:26:25 +01:00

46 lines
1.1 KiB
ObjectPascal

unit LoggerPro.SimpleConsoleAppender;
{ <@abstract(The unit to include if you want to use @link(TLoggerProSimpleConsoleAppender))
@author(David Cornelius) }
{$IFNDEF CONSOLE}
{$MESSAGE FATAL 'This unit should only be used in console applications'}
{$ENDIF}
interface
uses
System.Classes, System.SysUtils,
LoggerPro;
type
{ @abstract(This appender assumes the application is running from the console and simply uses Writeln
without any dependency on Windows to send logs to the current console; this allows console logging from Linux)
To learn how to use this appender, check the sample @code(SimpleConsole_appender.dproj)
}
TLoggerProSimpleConsoleAppender = class(TLoggerProAppenderBase)
public
procedure Setup; override;
procedure TearDown; override;
procedure WriteLog(const aLogItem: TLogItem); override;
end;
implementation
procedure TLoggerProSimpleConsoleAppender.Setup;
begin
inherited;
end;
procedure TLoggerProSimpleConsoleAppender.TearDown;
begin
// do nothing
end;
procedure TLoggerProSimpleConsoleAppender.WriteLog(const aLogItem: TLogItem);
begin
Writeln(FormatLog(aLogItem));
end;
end.