diff --git a/Options.cmake b/Options.cmake index fad8030..ec156b3 100644 --- a/Options.cmake +++ b/Options.cmake @@ -72,6 +72,17 @@ ELSE() ENDIF(USE_G3_DYNAMIC_MAX_MESSAGE_SIZE) +# G3LOG_FULL_FILENAME logs full file name instead of short filename. This makes it +# easier to copy filenames to open them without needing to search. +option (G3_LOG_FULL_FILENAME "Log full filename" OFF) +IF(G3_LOG_FULL_FILENAME) + LIST(APPEND G3_DEFINITIONS G3_LOG_FULL_FILENAME) + message( STATUS "-DG3_LOG_FULL_FILENAME=ON\t\tShowing full filenames with logs") +ELSE() + message( STATUS "-DG3_LOG_FULL_FILENAME=OFF") +ENDIF(G3_LOG_FULL_FILENAME) + + # -DENABLE_FATAL_SIGNALHANDLING=ON : defualt change the # By default fatal signal handling is enabled. You can disable it with this option # enumerated in src/stacktrace_windows.cpp diff --git a/src/g3log/g3log.hpp b/src/g3log/g3log.hpp index 011b033..fb1e540 100644 --- a/src/g3log/g3log.hpp +++ b/src/g3log/g3log.hpp @@ -150,7 +150,7 @@ namespace g3 { // 'Conditional' stream log #define LOG_IF(level, boolean_expression) \ - if(true == boolean_expression) \ + if(true == (boolean_expression)) \ if(g3::logLevel(level)) INTERNAL_LOG_MESSAGE(level).stream() // 'Design By Contract' stream API. For Broken Contracts: @@ -213,7 +213,7 @@ And here is possible output // Conditional log printf syntax #define LOGF_IF(level,boolean_expression, printf_like_message, ...) \ - if(true == boolean_expression) \ + if(true == (boolean_expression)) \ if(g3::logLevel(level)) INTERNAL_LOG_MESSAGE(level).capturef(printf_like_message, ##__VA_ARGS__) // Design By Contract, printf-like API syntax with variadic input parameters. diff --git a/src/logmessage.cpp b/src/logmessage.cpp index 675c50c..824d1e3 100644 --- a/src/logmessage.cpp +++ b/src/logmessage.cpp @@ -127,7 +127,11 @@ namespace g3 { const std::string& function, const LEVELS& level) : _timestamp(std::chrono::high_resolution_clock::now()) , _call_thread_id(std::this_thread::get_id()) +#if defined(G3_LOG_FULL_FILENAME) + , _file(file) +#else , _file(splitFileName(file)) +#endif , _file_path(file) , _line(line) , _function(function)