-
Notifications
You must be signed in to change notification settings - Fork 15
/
UProviderNotification.pas
79 lines (64 loc) · 1.68 KB
/
UProviderNotification.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
unit UProviderNotification;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Winapi.ShellAPI,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;
type
TForm2 = class(TForm)
Panel1: TPanel;
btnMakeLog: TButton;
pnlInfo: TPanel;
procedure btnMakeLogClick(Sender: TObject);
procedure pnlInfoClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
uses
DataLogger, DataLogger.Provider.Notification;
procedure TForm2.btnMakeLogClick(Sender: TObject);
begin
Logger
.Trace('My Trace')
.Debug('My Debug')
.Info('My Info')
.Warn('My Warn')
.Error('My Error')
.Success('My Success')
.Fatal('My Fatal')
.Custom('Custom Level', 'My Custom')
;
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
ReportMemoryLeaksOnShutdown := True;
Logger.AddProvider(
TProviderNotification.Create
.Title('DataLogger - Notification', False)
.ExecuteOnClick(
procedure(const ANotification: TNotification)
begin
ShowMessage(ANotification.AlertBody);
end)
);
// Log Format
Logger.SetLogFormat(TLoggerFormat.LOG_TIMESTAMP + ' - ' + TLoggerFormat.LOG_MESSAGE);
// Show only info and custom
Logger.SetOnlyLevel([TLoggerLevel.Info, TLoggerLevel.Custom]);
end;
procedure TForm2.pnlInfoClick(Sender: TObject);
var
LURL: string;
begin
LURL := pnlInfo.Caption;
LURL := LURL.Replace('GITHUB: ', '').Replace(' ', '');
ShellExecute(0, 'open', PChar(LURL), nil, nil, SW_SHOWNORMAL);
end;
end.