mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-17 08:45:55 +01:00
690031594c
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
61 lines
1.5 KiB
ObjectPascal
61 lines
1.5 KiB
ObjectPascal
unit MultipleLoggersU;
|
|
|
|
interface
|
|
|
|
uses
|
|
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
|
|
System.Classes, Vcl.Graphics,
|
|
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, LoggerPro, Vcl.StdCtrls;
|
|
|
|
type
|
|
TMultipleLoggersForm = class(TForm)
|
|
Memo1: TMemo;
|
|
btnFormLocalLog: TButton;
|
|
btnApplicationLevelLog: TButton;
|
|
procedure FormCreate(Sender: TObject);
|
|
procedure btnFormLocalLogClick(Sender: TObject);
|
|
procedure btnApplicationLevelLogClick(Sender: TObject);
|
|
private
|
|
FLogWriter: ILogWriter;
|
|
function LocalLog: ILogWriter;
|
|
public
|
|
{ Public declarations }
|
|
end;
|
|
|
|
var
|
|
MultipleLoggersForm: TMultipleLoggersForm;
|
|
|
|
implementation
|
|
|
|
uses
|
|
LoggerPro.VCLMemoAppender, LoggerProConfig;
|
|
|
|
{$R *.dfm}
|
|
|
|
procedure TMultipleLoggersForm.btnApplicationLevelLogClick(Sender: TObject);
|
|
begin
|
|
Log.Log(TLogType(Random(Ord(TLogType.Fatal) + 1)),
|
|
'Message sent to the application level LoggerPro instance (random type)',
|
|
'APP');
|
|
end;
|
|
|
|
procedure TMultipleLoggersForm.btnFormLocalLogClick(Sender: TObject);
|
|
begin
|
|
LocalLog.Log(TLogType(Random(Ord(TLogType.Fatal) + 1)),
|
|
'Message sent to the form local LoggerPro instance (random type)', 'tag');
|
|
end;
|
|
|
|
procedure TMultipleLoggersForm.FormCreate(Sender: TObject);
|
|
begin
|
|
FLogWriter := BuildLogWriter([TVCLMemoLogAppender.Create(Memo1)], nil,
|
|
TLogType.Info);
|
|
FLogWriter.Info('Local log correctly initialized', 'tag');
|
|
end;
|
|
|
|
function TMultipleLoggersForm.LocalLog: ILogWriter;
|
|
begin
|
|
Result := FLogWriter;
|
|
end;
|
|
|
|
end.
|