easyloggingpp
easyloggingpp copied to clipboard
On crash, log line number and file in source code
Hi,
Sorry if this is not the right place to ask for this, I am in urgent need for an answer.
I need to get line number and filename in source code when unhandled exception occurs.
but I am getting this instead, which is the line number inside the logging library.
2016-08-09 11:43:29,968 WARN easylogging++.h 5627 Aborting application. Reason: Fatal log at [ c:\vsprojects\loglibtest\loglibtest\easylogging++.h : 5627 ]
Can anyone help me solve the issue. below is sample code I'm using
#define ELPP_THREAD_SAFE
#define ELPP_CUSTOM_COUT std::cerr
#include "easylogging++.h"
#define _ELPP_STACKTRACE_ON_CRASH
INITIALIZE_EASYLOGGINGPP
void myCrashHandler(int sig)
{
LOG(ERROR) << "Application crashed!";
el::Helpers::logCrashReason(sig, true);
el::Loggers::flushAll();
el::Helpers::crashAbort(sig); // FOLLOWING LINE IS ABSOLUTELY NEEDED AT THE END IN ORDER TO ABORT APPLICATION
el::Loggers::flushAll();
}
void main()
{
el::Helpers::setCrashHandler(myCrashHandler);
el::Loggers::addFlag(el::LoggingFlag::LogDetailedCrashReason);
int* i;
*i = 0; // Crash!
return 0;
}
@mkhan3189 +1
Same problem with me:
CRASH HANDLED; Application has crashed due to [SIGSEGV] signal 2016-09-30 10:16:18,292 WARN [default] Aborting application. Reason: Fatal log at [/myuser/lib/easylogging++.h:5627]
+1
I had the same problem: 2016-11-12 23:45:23.507321 F easylogging++.h:5627 CRASH HANDLED; Application has crashed due to [SIGSEGV] signal
+1
F [2017-02-08 19:06:10] [easylogging++.h:5627] CRASH HANDLED; Application has crashed due to [SIGSEGV] signal W [2017-02-08 19:06:10] [easylogging++.h:5627] Aborting application. Reason: Fatal log at [./inc/easylogging++.h:5627]
I just rebooted my machine and the error is gone :)
Same behavior here:
2021-06-01 14:45:34,934666 - ERROR - Application crashed!
2021-06-01 14:45:34,934697 - FATAL - CRASH HANDLED; Application has crashed due to [SIGSEGV] signal
Invalid access to memory
Program is trying to read an invalid (unallocated, deleted or corrupted) or inaccessible memory.
======= Backtrace: =========
2021-06-01 14:45:34,934707 - WARNING - Aborting application. Reason: Fatal log at [/path/libs/easyloggingpp/src/easylogging++.cc:2884]
But in my case the Backtrace is empty. I have in my cmake lists:
add_definitions(-DELPP_NO_DEFAULT_LOG_FILE)
add_definitions(-DELPP_THREAD_SAFE)
add_definitions(-DELPP_FEATURE_CRASH_LOG)
target_compile_options(${PROJECT_NAME} PRIVATE -O3)
my gcc / OS are:
$ gcc --version
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Any ideas? Thanks!