Skip to content

Commit

Permalink
Log detailed crash reason closes #90
Browse files Browse the repository at this point in the history
  • Loading branch information
abumq committed Aug 18, 2013
1 parent 25d9cae commit f13b042
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,11 @@ Please note, this date/time functionality is built-in hence is cross-platform.
###Logging flags
Form some parts of logging you can set logging flags; here are flags supported:
| Flag | Description |
|------------------------------------|------------------------------------------------------------------------------------------------------------------|
| NewLineForContainer | Makes sure we have new line for each container log entry |
| Flag | Description |
|------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|
| NewLineForContainer | Makes sure we have new line for each container log entry |
| AllowVerboseIfModuleNotSpecified | Makes sure if -vmodule is used and does not specifies a module, then verbose logging is allowed via that module. Say param was -vmodule=main*=3 and a verbose log is being written from a file called something.cpp then if this flag is enabled, log will be written otherwise it will be disallowed. Note: having this defeats purpose of -vmodule |
| LogDetailedCrashReason | When handling crashes by default, detailed crash reason will be logged as well [issue #90](https://github.com/easylogging/easyloggingpp/issues/90) |
You can set these flags by using static el::Helpers::addFlag and el::Helpers::removeFlag. You can check to see if certain flag is available by using el::Helpers::hasFlag, all these functions take strong enums el::LoggingFlag
Expand Down
16 changes: 12 additions & 4 deletions src/easylogging++.h
Original file line number Diff line number Diff line change
Expand Up @@ -614,13 +614,17 @@ class ConfigurationTypeHelper: private base::StaticClass {
enum class LoggingFlag : unsigned short {
/// @brief Makes sure we have new line for each container log entry
NewLineForContainer = 1,

/// @brief Makes sure if -vmodule is used and does not specifies a module, then verbose
/// logging is allowed via that module.
///
/// @detail Say param was -vmodule=main*=3 and a verbose log is being written from a file
/// called something.cpp then if this flag is enabled, log will be written otherwise
/// it will be disallowed.
AllowVerboseIfModuleNotSpecified = 2
AllowVerboseIfModuleNotSpecified = 2,

/// @brief When handling crashes by default, detailed crash reason will be logged as well
LogDetailedCrashReason
};

namespace base {
Expand Down Expand Up @@ -3127,6 +3131,7 @@ class Storage : private base::NoCopy {
performanceLogger->refConfigurations().setGlobally(ConfigurationType::Format, "%datetime %level %log");
performanceLogger->reconfigure();
addFlag(LoggingFlag::AllowVerboseIfModuleNotSpecified);
addFlag(LoggingFlag::LogDetailedCrashReason);
}

virtual ~Storage(void) {
Expand Down Expand Up @@ -4056,9 +4061,12 @@ static void logCrashReason(int sig, bool stackTraceIfAvailable, const Level& lev
if (base::consts::kCrashSignals[i].numb == sig) {
ss << "Application has crashed due to [" <<
base::consts::kCrashSignals[i].name <<
"] signal" << std::endl <<
" " << base::consts::kCrashSignals[i].brief << std::endl <<
" " << base::consts::kCrashSignals[i].detail;
"] signal";
if (base::elStorage->hasFlag(el::LoggingFlag::LogDetailedCrashReason)) {
ss << std::endl <<
" " << base::consts::kCrashSignals[i].brief << std::endl <<
" " << base::consts::kCrashSignals[i].detail;
}
foundReason = true;
}
}
Expand Down

0 comments on commit f13b042

Please sign in to comment.