Esempio n. 1
0
File: log.cpp Progetto: ronj/invent
 /** Same as the Shutdown above but called by the destructor of the LogWorker, thus ensuring that no further
  *  LOG(...) calls can happen to  a non-existing LogWorker. 
  *  @param active MUST BE the LogWorker initialized for logging. If it is not then this call is just ignored
  *         and the logging continues to be active.
  * @return true if the correct worker was given,. and shutDownLogging was called 
  */
 bool shutDownLoggingForActiveOnly(LogWorker* active) {
    if (isLoggingInitialized() && nullptr != active && (active != g_logger_instance)) {
       LOG(WARNING) << "\n\t\tAttempted to shut down logging, but the ID of the Logger is not the one that is active."
               << "\n\t\tHaving multiple instances of the g2::LogWorker is likely a BUG"
               << "\n\t\tEither way, this call to shutDownLogging was ignored"
               << "\n\t\tTry g2::internal::shutDownLogging() instead";
       return false;
    }
    shutDownLogging();
    return true;
 }
Esempio n. 2
0
File: log.cpp Progetto: ronj/invent
 /** Fatal call saved to logger. This will trigger SIGABRT or other fatal signal 
  * to exit the program. After saving the fatal message the calling thread
  * will sleep forever (i.e. until the background thread catches up, saves the fatal
  * message and kills the software with the fatal signal.
  */
 void fatalCallToLogger(FatalMessagePtr message) {
    if (!isLoggingInitialized()) {
       std::ostringstream error;
       error << "FATAL CALL but logger is NOT initialized\n"
               << "SIGNAL: " << message.get()->signal()
               << "\nMessage: \n" << message.get()->toString() << std::flush;
       std::cerr << error.str() << std::flush;
       internal::exitWithDefaultSignalHandler(message.get()->_signal_id);
    }
    g_logger_instance->fatal(message);
    while (true) {
       std::this_thread::sleep_for(std::chrono::seconds(1));
    }
 }
Esempio n. 3
0
 /** Fatal call saved to logger. This will trigger SIGABRT or other fatal signal
  * to exit the program. After saving the fatal message the calling thread
  * will sleep forever (i.e. until the background thread catches up, saves the fatal
  * message and kills the software with the fatal signal.
  */
 void pushFatalMessageToLogger(FatalMessagePtr message) {
    if (!isLoggingInitialized()) {
       std::ostringstream error;
       error << "FATAL CALL but logger is NOT initialized\n"
             << "CAUSE: " << message.get()->reason()
             << "\nMessage: \n" << message.get()->toString() << std::flush;
       std::cerr << error.str() << std::flush;
       internal::exitWithDefaultSignalHandler(message.get()->_level, message.get()->_signal_id);
    }
    g_logger_instance->fatal(message);
    while (shouldBlockForFatalHandling()) {
       std::this_thread::sleep_for(std::chrono::seconds(1));
    }
 }