From d09ca7787d77f34161f596116663e682ccd1eb0e Mon Sep 17 00:00:00 2001 From: Kjell Hedstrom Date: Wed, 22 Jul 2015 13:28:10 -0600 Subject: [PATCH] use the genereated_definitions.hpp --- Options.cmake | 34 ++++++++++++++++------------------ src/g3log/crashhandler.hpp | 3 ++- src/g3log/loglevels.hpp | 1 + src/loglevels.cpp | 5 ----- 4 files changed, 19 insertions(+), 24 deletions(-) diff --git a/Options.cmake b/Options.cmake index 43c2cbc..5689740 100644 --- a/Options.cmake +++ b/Options.cmake @@ -9,6 +9,14 @@ # =================================================================== +# PLEASE NOTE THAT: +# the following definitions can through options be added +# to the auto generated file src/g3log/generated_definitions.hpp +# add_definitions(-DG3_DYNAMIC_LOGGING) +# add_definitions(-DCHANGE_G3LOG_DEBUG_TO_DBUG) +# add_definitions(-DDISABLE_FATAL_SIGNALHANDLING) +# add_definitions(-DDISABLE_VECTORED_EXCEPTIONHANDLING) +# add_definitions(-DDEBUG_BREAK_AT_FATAL_SIGNAL) @@ -23,9 +31,8 @@ option (USE_DYNAMIC_LOGGING_LEVELS "Turn ON/OFF log levels. An disabled level will not push logs of that level to the sink. By default dynamic logging is disabled" OFF) IF(USE_DYNAMIC_LOGGING_LEVELS) LIST(APPEND G3_DEFINITIONS G3_DYNAMIC_LOGGING) - add_definitions(-DG3_DYNAMIC_LOGGING) MESSAGE("-DUSE_DYNAMIC_LOGGING_LEVELS=ON") - MESSAGE("\tDynamic logging levels can be turned on. Make sure to have [#define G3_DYNAMIC_LOGGING 1] in your source code") + MESSAGE("\tDynamic logging levels is used") MESSAGE("\tUse [g3::setLogLevel(LEVEL boolean)] to enable/disable logging on specified levels\n\n") ELSE() MESSAGE("-DUSE_DYNAMIC_LOGGING_LEVELS=OFF") @@ -40,10 +47,8 @@ option (CHANGE_G3LOG_DEBUG_TO_DBUG "Use DBUG logging level instead of DEBUG. By default DEBUG is the debugging level" OFF) IF(CHANGE_G3LOG_DEBUG_TO_DBUG) LIST(APPEND G3_DEFINITIONS CHANGE_G3LOG_DEBUG_TO_DBUG) - add_definitions(-DCHANGE_G3LOG_DEBUG_TO_DBUG) - MESSAGE("-DCHANGE_G3LOG_DEBUG_TO_DBUG=ON DBUG instead of DEBUG logging level can be used. Make sure to have:") - MESSAGE(" [#define CHANGE_G3LOG_DEBUG_TO_DBUG 1] in your source code") -ELSE() + MESSAGE("-DCHANGE_G3LOG_DEBUG_TO_DBUG=ON DBUG instead of DEBUG logging level is used") + ELSE() MESSAGE("-DCHANGE_G3LOG_DEBUG_TO_DBUG=OFF \t(Debuggin logging level is 'DEBUG')") ENDIF(CHANGE_G3LOG_DEBUG_TO_DBUG) @@ -57,9 +62,8 @@ option (ENABLE_FATAL_SIGNALHANDLING IF(NOT ENABLE_FATAL_SIGNALHANDLING) LIST(APPEND G3_DEFINITIONS DISABLE_FATAL_SIGNALHANDLING) - add_definitions(-DDISABLE_FATAL_SIGNALHANDLING) - MESSAGE("-DENABLE_FATAL_SIGNALHANDLING=OFF Fatal signal handler is disabled. Make sure to have:") - MESSAGE(" [#define DISABLE_FATAL_SIGNALHANDLING 1] in your source code") + + MESSAGE("-DENABLE_FATAL_SIGNALHANDLING=OFF Fatal signal handler is disabled") ELSE() MESSAGE("-DENABLE_FATAL_SIGNALHANDLING=ON\tFatal signal handler is enabled") ENDIF(NOT ENABLE_FATAL_SIGNALHANDLING) @@ -75,10 +79,7 @@ IF (MSVC OR MINGW) IF(NOT ENABLE_VECTORED_EXCEPTIONHANDLING) LIST(APPEND G3_DEFINITIONS DISABLE_VECTORED_EXCEPTIONHANDLING) - add_definitions(-DDISABLE_VECTORED_EXCEPTIONHANDLING) - MESSAGE("-DENABLE_VECTORED_EXCEPTIONHANDLING=OFF Vectored exception handling is disabled. Make sure to have:") - MESSaGE(" [#define DISABLE_VECTORED_EXCEPTIONHANDLING 1] in your source code") - + MESSAGE("-DENABLE_VECTORED_EXCEPTIONHANDLING=OFF Vectored exception handling is disabled") ELSE() MESSAGE("-DENABLE_VECTORED_EXCEPTIONHANDLING=ON\t\t\tVectored exception handling is enabled") ENDIF(NOT ENABLE_VECTORED_EXCEPTIONHANDLING) @@ -90,18 +91,15 @@ IF (MSVC OR MINGW) # receives a fatal signal. # option (DEBUG_BREAK_AT_FATAL_SIGNAL - "Enable Visual Studio break point when receiving a fatal exception. In __DEBUG mode only" ON) + "Enable Visual Studio break point when receiving a fatal exception. In __DEBUG mode only" OFF) IF(DEBUG_BREAK_AT_FATAL_SIGNAL) LIST(APPEND G3_DEFINITIONS DEBUG_BREAK_AT_FATAL_SIGNAL) - add_definitions(-DDEBUG_BREAK_AT_FATAL_SIGNAL) - MESSAGE("-DDEBUG_BREAK_AT_FATAL_SIGNAL=ON Break point for fatal signal is enabled for __DEBUG.Make sure to have:") - MESSAGE(" [#define DEBUG_BREAK_AT_FATAL_SIGNAL 1] in your source code") + MESSAGE("-DDEBUG_BREAK_AT_FATAL_SIGNAL=ON Break point for fatal signal is enabled for __DEBUG.") ELSE() MESSAGE("-DDEBUG_BREAK_AT_FATAL_SIGNAL=OFF\t\t\tBreak point for fatal signal is disabled") ENDIF(DEBUG_BREAK_AT_FATAL_SIGNAL) ENDIF (MSVC OR MINGW) - MESSAGE("\n\n\n") diff --git a/src/g3log/crashhandler.hpp b/src/g3log/crashhandler.hpp index 07d9f2e..3417b5a 100644 --- a/src/g3log/crashhandler.hpp +++ b/src/g3log/crashhandler.hpp @@ -10,7 +10,8 @@ #include #include #include "g3log/loglevels.hpp" - +#include "g3log/generated_definitions.hpp" + // kjell. Separera på crashhandler.hpp och crashhanlder_internal.hpp // implementationsfilen kan vara den samma namespace g3 { diff --git a/src/g3log/loglevels.hpp b/src/g3log/loglevels.hpp index 8b54ae2..884afbf 100644 --- a/src/g3log/loglevels.hpp +++ b/src/g3log/loglevels.hpp @@ -7,6 +7,7 @@ * ============================================================================*/ #pragma once +#include "g3log/generated_definitions.hpp" // Users of Juce or other libraries might have a define DEBUG which clashes with // the DEBUG logging level for G3log. In that case they can instead use the define diff --git a/src/loglevels.cpp b/src/loglevels.cpp index 94349b3..78c1edc 100644 --- a/src/loglevels.cpp +++ b/src/loglevels.cpp @@ -41,11 +41,6 @@ namespace g3 { } #ifdef G3_DYNAMIC_LOGGING - // All levels are by default ON: i.e. for DEBUG, INFO, WARNING, FATAL - const int g_level_size { - FATAL.value + 1 - }; - //std::atomic g_log_level_status[4] {{true}, {true}, {true}, {true}}; std::map g_log_level_status = {{g3::kDebugVaulue, true}, {INFO.value, true}, {WARNING.value, true}, {FATAL.value, true}}; #endif } // internal