delphimvcframework/samples/130_simple_console_appender/SimpleConsole_appender.dpr
Daniele Teti 690031594c Squashed 'lib/loggerpro/' changes from 100b0ce0..0d39e1d1
0d39e1d1 New LogLevel: FATAL
5248b9de Improved fileformatname check
657a539d https://github.com/danieleteti/loggerpro/issues/79
67729f57 https://github.com/danieleteti/loggerpro/issues/72
f05a91a6 https://github.com/danieleteti/loggerpro/issues/73
3c805c0f Merge pull request #71 from luebbe/master
3a790459 Fixes #70 Add test to expose #70

git-subtree-dir: lib/loggerpro
git-subtree-split: 0d39e1d1549d42fa20b71503eed944043771b7bb
2023-10-18 16:25:23 +02:00

42 lines
1.1 KiB
ObjectPascal

program SimpleConsole_appender;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils, System.Classes, System.Threading,
LoggerPro,
LoggerPro.SimpleConsoleAppender;
const
MAX_TASK = 5;
var
lTasks: array of ITask;
lLog: ILogWriter;
begin
lLog := BuildLogWriter([TLoggerProSimpleConsoleAppender.Create]);
Setlength (lTasks, MAX_TASK);
for var i := 0 to MAX_TASK - 1 do begin
lTasks[i] := TTask.Create(procedure
var
I: Integer;
lThreadID: string;
begin
lThreadID := TTask.CurrentTask.Id.ToString;
for I := 1 to 200 do
begin
lLog.Debug('log message ' + TimeToStr(now) + ' ThreadID: ' + lThreadID, 'MULTITHREADING');
lLog.Info('log message ' + TimeToStr(now) + ' ThreadID: ' + lThreadID, 'MULTITHREADING');
lLog.Warn('log message ' + TimeToStr(now) + ' ThreadID: ' + lThreadID, 'MULTITHREADING');
lLog.Error('log message ' + TimeToStr(now) + ' ThreadID: ' + lThreadID, 'MULTITHREADING');
lLog.Fatal('log message ' + TimeToStr(now) + ' ThreadID: ' + lThreadID, 'MULTITHREADING');
end;
end);
lTasks[i].Start;
end;
TTask.WaitForAll(lTasks);
end.