mirror of
https://github.com/KjellKod/g3log.git
synced 2024-12-12 10:23:50 +01:00
Fix compiler warnings and condition check improvements (#390)
* fix compiler warnings - loglevels.cpp - warns about double return if dynamic logging is on - crash handler_unix.cpp - warns about unused variable
This commit is contained in:
parent
c0ae589024
commit
2fca06ff6d
@ -59,7 +59,7 @@ namespace {
|
||||
// Dump of stack,. then exit through g3log background worker
|
||||
// ALL thanks to this thread at StackOverflow. Pretty much borrowed from:
|
||||
// Ref: http://stackoverflow.com/questions/77005/how-to-generate-a-stacktrace-when-my-gcc-c-app-crashes
|
||||
void signalHandler(int signal_number, siginfo_t* info, void* unused_context) {
|
||||
void signalHandler(int signal_number, siginfo_t* /*info*/, void* /*unused_context*/) {
|
||||
|
||||
// Only one signal will be allowed past this point
|
||||
if (false == shouldDoExit()) {
|
||||
|
@ -145,12 +145,12 @@ namespace g3 {
|
||||
|
||||
|
||||
// LOG(level) is the API for the stream log
|
||||
#define LOG(level) if(!g3::logLevel(level)) {} else INTERNAL_LOG_MESSAGE(level).stream()
|
||||
#define LOG(level) if (!g3::logLevel(level)) {} else INTERNAL_LOG_MESSAGE(level).stream()
|
||||
|
||||
|
||||
// 'Conditional' stream log
|
||||
#define LOG_IF(level, boolean_expression) \
|
||||
if (false == (boolean_expression) || !g3::logLevel(level)) {} else INTERNAL_LOG_MESSAGE(level).stream()
|
||||
if (!g3::logLevel(level) || false == (boolean_expression)) {} else INTERNAL_LOG_MESSAGE(level).stream()
|
||||
|
||||
// 'Design By Contract' stream API. Broken Contracts will exit the application by using fatal signal SIGABRT
|
||||
// For unit testing, you can override the fatal handling using setFatalExitHandler(...). See tes_io.cpp for examples
|
||||
@ -211,7 +211,7 @@ And here is possible output
|
||||
|
||||
// Conditional log printf syntax
|
||||
#define LOGF_IF(level,boolean_expression, printf_like_message, ...) \
|
||||
if (false == (boolean_expression) || !g3::logLevel(level)) {} else INTERNAL_LOG_MESSAGE(level).capturef(printf_like_message, ##__VA_ARGS__)
|
||||
if (!g3::logLevel(level) || false == (boolean_expression)) {} else INTERNAL_LOG_MESSAGE(level).capturef(printf_like_message, ##__VA_ARGS__)
|
||||
|
||||
// Design By Contract, printf-like API syntax with variadic input parameters.
|
||||
// Calls the signal handler if the contract failed with the default exit for a failed contract. This is typically SIGABRT
|
||||
|
@ -132,7 +132,8 @@ namespace g3 {
|
||||
int level = log_level.value;
|
||||
bool status = internal::g_log_levels[level].status.value();
|
||||
return status;
|
||||
#endif
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
} // g3
|
||||
|
Loading…
Reference in New Issue
Block a user