Skip to content

Commit 811fd9b

Browse files
committed
limit the number of logged stacktraces of Windows exceptions
1 parent db2a5c7 commit 811fd9b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

source/MRMesh/MRLogWindowsExceptions.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ constexpr auto EXCEPTION_CXX = 0xE06D7363L; // c++ throw ...
1616
constexpr auto MS_VC_EXCEPTION = 0x406D1388L; // thread renaming
1717
constexpr auto RPC_UNAVAILABLE = 0x000006BAL; // thrown in file dialog
1818

19+
// we limit the number of logged stacktraces since typically only the first exception is of any interest,
20+
// and the following ones are either repetitions or consequences of the first exception which only make the log huge
21+
int numMoreStacktraces = 5;
22+
1923
LONG WINAPI logWindowsException( LPEXCEPTION_POINTERS pExInfo )
2024
{
2125
thread_local bool logging = false;
@@ -70,10 +74,14 @@ LONG WINAPI logWindowsException( LPEXCEPTION_POINTERS pExInfo )
7074
spdlog::info( "Wide debug information: {}", Utf16ToUtf8( std::wstring_view( p, len ) ) );
7175
}
7276
else
73-
spdlog::critical( "Windows exception {:#010x}", pExceptionRecord->ExceptionCode );
77+
spdlog::warn( "Windows exception {:#010x}", pExceptionRecord->ExceptionCode );
7478

75-
spdlog::info( "Windows exception stacktrace:\n{}", getCurrentStacktrace() );
76-
printCurrentTimerBranch();
79+
if ( numMoreStacktraces > 0 )
80+
{
81+
--numMoreStacktraces;
82+
spdlog::info( "Windows exception stacktrace:\n{}", getCurrentStacktrace() );
83+
printCurrentTimerBranch();
84+
}
7785
logging = false;
7886
return EXCEPTION_CONTINUE_SEARCH;
7987
}

0 commit comments

Comments
 (0)