diff --git a/g2log/CMakeLists.txt b/g2log/CMakeLists.txt index 5f9e632..8837760 100644 --- a/g2log/CMakeLists.txt +++ b/g2log/CMakeLists.txt @@ -75,8 +75,18 @@ IF(UNIX) # -D_GLIBCXX_USE_NANOSLEEP is needed for this_thread sleep (unit testing) set(CMAKE_CXX_FLAGS "-Wall -rdynamic -Wunused -std=c++11 ${CMAKE_CXX_FLAGS_DEBUG} -pthread -D_GLIBCXX_USE_NANOSLEEP") set(SRC_PLATFORM_SPECIFIC ${LOG_SRC}/crashhandler_unix.cpp) - ENDIF(UNIX) +ENDIF(UNIX) +IF(MINGW) + MESSAGE("") + MESSAGE("cmake for MinGW ") + MESSAGE("if cmake finishes OK, do make") + MESSAGE("then run './g2log-FATAL-example' or whatever performance test you feel like trying") + MESSAGE("") + # -D_GLIBCXX_USE_NANOSLEEP is needed for this_thread sleep (unit testing) + set(CMAKE_CXX_FLAGS "-Wall -Wunused -std=c++11 ${CMAKE_CXX_FLAGS_DEBUG} -pthread -D_GLIBCXX_USE_NANOSLEEP") + set(SRC_PLATFORM_SPECIFIC ${LOG_SRC}/crashhandler_win.cpp) +ENDIF(MINGW) # Visual Studio 2011 -- std::thread etc are included with the Visual Studio package, so justthread dependencies are removed IF(MSVC) @@ -100,11 +110,11 @@ ENDIF(MSVC) # GENERIC STEPS file(GLOB SRC_FILES ${LOG_SRC}/*.h ${LOG_SRC}/*.hpp ${LOG_SRC}/*.cpp ${LOG_SRC}/*.ipp) - if(MSVC) + if(MSVC OR MINGW) list(REMOVE_ITEM SRC_FILES ${LOG_SRC}/crashhandler_unix.cpp) else() list(REMOVE_ITEM SRC_FILES ${LOG_SRC}/crashhandler_win.cpp) - endif(MSVC) + endif(MSVC OR MINGW) set(SRC_FILES ${SRC_FILES} ${SRC_PLATFORM_SPECIFIC}) @@ -126,7 +136,7 @@ ENDIF(MSVC) # (or change the default option above) if(USE_DYNAMIC_LOGGING_LEVELS) add_definitions(-DG2_DYNAMIC_LOGGING) - MESSAGE ("\nUSE_DYNAMIC_LOGGING_LEVELS is turned on"\n\t"Use g2::setLogLevel(LEVEL boolean) to enable/disable logging on specified levels.\n\tAll levels are by default turn ON\n\n") + MESSAGE ("\nUSE_DYNAMIC_LOGGING_LEVELS is turned on\n\tUse g2::setLogLevel(LEVEL boolean) to enable/disable logging on specified levels.\n\tAll levels are by default turn ON\n\n") endif(USE_DYNAMIC_LOGGING_LEVELS) diff --git a/g2log/src/crashhandler_win.cpp b/g2log/src/crashhandler_win.cpp index cad38cf..a3aaff3 100644 --- a/g2log/src/crashhandler_win.cpp +++ b/g2log/src/crashhandler_win.cpp @@ -5,11 +5,13 @@ * ============================================================================*/ #include "crashhandler.hpp" -#include "g2log.hpp" +#include "g2logmessage.hpp" +#include "g2LogMessageBuilder.hpp" #include #include #include +#include #if !(defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) #error "crashhandler_win.cpp used but not on a windows system" #endif @@ -26,9 +28,10 @@ void crashHandler(int signal_number) fatal_stream << "\n\n***** FATAL TRIGGER RECEIVED ******* " << std::endl; fatal_stream << "\n***** RETHROWING SIGNAL " << signalName(signal_number) << "(" << signal_number << ")" << std::endl; - FatalMessage fatal_message(fatal_stream.str(),FatalMessage::kReasonOS_FATAL_SIGNAL, signal_number); - FatalMessageBuilder trigger(fatal_message); std::ostringstream oss; - std::cerr << fatal_message.message_ << std::endl << std::flush; + //FatalMessage fatal_message(fatal_stream.str(),FatalMessage::kReasonOS_FATAL_SIGNAL, signal_number); + g2::FatalMessageBuilder trigger(fatal_stream.str(), signal_number); + //std::ostringstream oss; + //std::cerr << fatal_message.message_ << std::endl << std::flush; } // scope exit - message sent to LogWorker, wait to die... } // end anonymous namespace @@ -37,6 +40,12 @@ namespace g2 { namespace internal { +std::string stackdump() +{ + std::string temp; + return temp; +} + std::string signalName(int signal_number) { switch(signal_number) diff --git a/g2log/src/g2filesinkhelper.ipp b/g2log/src/g2filesinkhelper.ipp index 01c0175..1a436be 100644 --- a/g2log/src/g2filesinkhelper.ipp +++ b/g2log/src/g2filesinkhelper.ipp @@ -40,6 +40,7 @@ namespace g2 { prefix.erase(std::remove(prefix.begin(), prefix.end(), '/'), prefix.end()); prefix.erase(std::remove(prefix.begin(), prefix.end(), '\\'), prefix.end()); prefix.erase(std::remove(prefix.begin(), prefix.end(), '.'), prefix.end()); + prefix.erase(std::remove(prefix.begin(), prefix.end(), ':'), prefix.end()); if (!isValidFilename(prefix)) { return { diff --git a/g2log/src/g2time.cpp b/g2log/src/g2time.cpp index 6906f50..8ddfa7a 100644 --- a/g2log/src/g2time.cpp +++ b/g2log/src/g2time.cpp @@ -27,7 +27,7 @@ namespace g2 { // return value is SIMPLIFIED to only return a std::string std::string put_time(const struct tm* tmb, const char* c_time_format) { -#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) +#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) && !defined(__MINGW32__) std::ostringstream oss; oss.fill('0'); // BOGUS hack done for VS2012: C++11 non-conformant since it SHOULD take a "const struct tm* " diff --git a/g2log/test_unit/test_io.cpp b/g2log/test_unit/test_io.cpp index f263f26..15402e5 100644 --- a/g2log/test_unit/test_io.cpp +++ b/g2log/test_unit/test_io.cpp @@ -245,6 +245,7 @@ TEST(LogTest, LOG_IF__FATAL) { TEST(LogTest, LOG_IF__FATAL__NO_THROW) { RestoreFileLogger logger(log_directory); LOG_IF(FATAL, (2 > 3)) << "This message%sshould NOT throw"; + logger.reset(); ASSERT_FALSE(mockFatalWasCalled()); } @@ -304,6 +305,7 @@ TEST(CHECK, CHECK_ThatWontThrow) { CHECK(1 == 1); CHECK_F(1 == 1, msg.c_str(), "message", "log"); + logger.reset(); EXPECT_FALSE(mockFatalWasCalled()); std::string file_content = readFileToText(logger.logFile()); diff --git a/g2log/test_unit/test_sink.cpp b/g2log/test_unit/test_sink.cpp index 737b791..38665f1 100644 --- a/g2log/test_unit/test_sink.cpp +++ b/g2log/test_unit/test_sink.cpp @@ -50,7 +50,7 @@ TEST(ConceptSink, OneHundredSinks) { } { - RestoreFileLogger logger{"/tmp"}; + RestoreFileLogger logger{"./"}; g2::LogWorker* worker = logger._scope->get(); //g2LogWorker::createWithNoSink(); size_t index = 0; for (auto& flag : flags) { @@ -69,6 +69,8 @@ TEST(ConceptSink, OneHundredSinks) { write2.append("Hello to 100 receivers :)"); worker->save(message2); LOG(INFO) << "end message"; + + logger.reset(); } // at the curly brace above the ScopedLogger will go out of scope and all the // 100 logging receivers will get their message to exit after all messages are