Skip to content

Commit 6720abf

Browse files
committed
feat: Log ERR
1 parent b96ef44 commit 6720abf

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

src/bot/irclogbot.bot.pas

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ procedure TIRCLogBot.OnPrivateMessage(ASender: TIdContext; const ANickname,
165165
except
166166
on e:Exception do
167167
begin
168+
error('Replay error: %s', [e.Message]);
168169
FIRC.Say(ANickname, 'Something went wrong: "' + e.Message + '". It''s been logged. Please contact the admin if I stop working.');
169170
end;
170171
end;
@@ -252,7 +253,7 @@ procedure TIRCLogBot.Run;
252253
except
253254
on e:Exception do
254255
begin
255-
debug('Error connecting: "%s".', [e.Message]);
256+
error('Error connecting: "%s".', [e.Message]);
256257
end;
257258
end;
258259
try
@@ -261,7 +262,7 @@ procedure TIRCLogBot.Run;
261262
except
262263
on e:Exception do
263264
begin
264-
debug('Error joining: "%s".', [e.Message]);
265+
error('Error joining: "%s".', [e.Message]);
265266
end;
266267
end;
267268
debug('Starting Replay Thread.');
@@ -283,7 +284,7 @@ procedure TIRCLogBot.Shutdown;
283284
except
284285
on e:Exception do
285286
begin
286-
debug('Error disconnecting: "%s".', [e.Message]);
287+
error('Error disconnecting: "%s".', [e.Message]);
287288
end;
288289
end;
289290
end;
@@ -316,7 +317,7 @@ constructor TIRCLogBot.Create(const AConfig: TBotConfig);
316317
except
317318
on e:Exception do
318319
begin
319-
debug('Error creating db: "%s".', [e.Message]);
320+
error('Error creating db: "%s".', [e.Message]);
320321
end;
321322
end;
322323
end;

src/common/irclogbot.common.pas

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ interface
1717

1818
procedure info(const AMessage: String); overload;
1919
procedure info(const AFormat: String; AValues: array of const);overload;
20+
procedure error(const AMessage: String); overload;
21+
procedure error(const AFormat: String; AValues: array of const);overload;
2022
procedure debug(const AMessage: String); overload;
2123
procedure debug(const AFormat: String; AValues: array of const);overload;
2224

2325
implementation
2426

2527
type
26-
TLogLevel = (llInfo, llDebug);
28+
TLogLevel = (llInfo, llError, llDebug);
2729

2830
var
2931
dateTimeStr: String;
@@ -35,6 +37,9 @@ procedure log(const ALevel: TLogLevel; const AMessage: String);
3537
llInfo:begin
3638
WriteLn(dateTimeStr, '[INF]: ', AMessage);
3739
end;
40+
llError:begin
41+
WriteLn(dateTimeStr, '[ERR]: ', AMessage);
42+
end;
3843
llDebug:begin
3944
WriteLn(dateTimeStr, '[DBG]: ', AMessage);
4045
end;
@@ -52,6 +57,16 @@ procedure info(const AFormat: String; AValues: array of const);
5257
Log(llInfo, Format(AFormat, AValues));
5358
end;
5459

60+
procedure error(const AMessage: String);
61+
begin
62+
Log(llError, AMessage);
63+
end;
64+
65+
procedure error(const AFormat: String; AValues: array of const);
66+
begin
67+
Log(llError, Format(AFormat, AValues));
68+
end;
69+
5570
procedure debug(const AMessage: String);
5671
begin
5772
if DebugOn then

src/database/irclogbot.database.pas

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ procedure TDatabase.SetupTables;
5656
on e:Exception do
5757
begin
5858
FTransaction.Rollback;
59-
debug('Error setting tables: "%s".', [e.Message]);
59+
error('Error setting tables: "%s".', [e.Message]);
6060
end;
6161
end;
6262
end;
@@ -81,7 +81,7 @@ procedure TDatabase.Insert(const ANickName, AChannel, AMessage: String);
8181
on e:Exception do
8282
begin
8383
FTransaction.Rollback;
84-
debug('Error inserting message: "%s".', [e.Message]);
84+
error('Error inserting message: "%s".', [e.Message]);
8585
end;
8686
end;
8787
finally
@@ -137,7 +137,7 @@ function TDatabase.Get(const ACount: Integer): TStringList;
137137
on e:Exception do
138138
begin
139139
FTransaction.Rollback;
140-
debug('Error retrieving lines: "%s".', [e.Message]);
140+
error('Error retrieving lines: "%s".', [e.Message]);
141141
end;
142142
end;
143143
finally
@@ -197,7 +197,7 @@ function TDatabase.Search(const AQuery: String): TStringList;
197197
on e:Exception do
198198
begin
199199
FTransaction.Rollback;
200-
debug('Error retrieving lines: "%s".', [e.Message]);
200+
error('Error retrieving lines: "%s".', [e.Message]);
201201
end;
202202
end;
203203
finally

0 commit comments

Comments
 (0)