Skip to content

Commit 6821106

Browse files
author
Arnaud Bouchez
committed
core: new TSynLog.NoLibraryException property
1 parent 9bcfeb3 commit 6821106

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/core/mormot.core.log.pas

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ TSynLogFamily = class
692692
fNoEnvironmentVariable: boolean;
693693
{$endif OSWINDOWS}
694694
{$ifndef NOEXCEPTIONINTERCEPT}
695-
fHandleExceptions: boolean;
695+
fHandleExceptions, fNoLibraryException: boolean;
696696
fOnBeforeException: TOnBeforeException;
697697
{$endif NOEXCEPTIONINTERCEPT}
698698
fAutoFlushTimeOut: cardinal;
@@ -798,6 +798,10 @@ TSynLogFamily = class
798798
// to this flag
799799
property ExceptionIgnoreCurrentThread: boolean
800800
index tiExceptionIgnore read GetCurrentThreadFlag write SetCurrentThreadFlag;
801+
/// set true will log exceptions only from the main executable, not from library
802+
// - will follow IsMainExecutable() result
803+
property NoLibraryException: boolean
804+
read fNoLibraryException write fNoLibraryException;
801805
/// allow to temporarly avoid logging in the current thread
802806
// - won't affect exceptions logging, as one would expect for safety reasons
803807
// - after setting true to this property, should eventually be reset to false:
@@ -6490,7 +6494,11 @@ procedure SynLogException(const Ctxt: TSynLogExceptionContext);
64906494
exit; // disabled for this thread (avoid nested call)
64916495
log := HandleExceptionFamily.Add;
64926496
if log = nil then
6493-
exit;
6497+
exit;
6498+
if log.fFamily.NoLibraryException and
6499+
(Ctxt.EAddr <> 0) and
6500+
not IsMainExecutable(pointer(Ctxt.EAddr)) then // fast guess
6501+
exit;
64946502
thrdnam := CurrentThreadNameShort;
64956503
log.LockAndDisableExceptions; // ignore result = tiTemporaryDisable flag
64966504
try

src/mormot.commit.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
'2.3.13062'
1+
'2.3.13063'

0 commit comments

Comments
 (0)