Try to always log when exiting.

This commit is contained in:
Jacob Dufault 2017-11-18 11:02:09 -08:00
parent 6a50c48aaa
commit 0376da015f
2 changed files with 14 additions and 9 deletions

View File

@ -1459,7 +1459,7 @@ bool QueryDbMainLoop(Config* config,
// Make sure cache directory is valid. // Make sure cache directory is valid.
if (config->cacheDirectory.empty()) { if (config->cacheDirectory.empty()) {
LOG_S(ERROR) << "No cache directory"; LOG_S(FATAL) << "Exiting; no cache directory";
exit(1); exit(1);
} }
config->cacheDirectory = NormalizePath(config->cacheDirectory); config->cacheDirectory = NormalizePath(config->cacheDirectory);
@ -1596,6 +1596,7 @@ bool QueryDbMainLoop(Config* config,
} }
case IpcId::Exit: { case IpcId::Exit: {
LOG_S(INFO) << "Exiting; got IpcId::Exit";
exit(0); exit(0);
break; break;
} }
@ -2926,8 +2927,8 @@ bool QueryDbMainLoop(Config* config,
} }
default: { default: {
LOG_S(INFO) << "[querydb] Unhandled IPC message " LOG_S(FATAL) << "Exiting; unhandled IPC message "
<< IpcIdToString(message->method_id); << IpcIdToString(message->method_id);
exit(1); exit(1);
} }
} }
@ -2978,8 +2979,10 @@ void RunQueryDbThread(const std::string& bin_name,
signature_cache.get()); signature_cache.get());
// No more work left and exit request. Exit. // No more work left and exit request. Exit.
if (!did_work && exit_when_idle && WorkThread::num_active_threads == 0) if (!did_work && exit_when_idle && WorkThread::num_active_threads == 0) {
LOG_S(INFO) << "Exiting; exit_when_idle is set and there is no more work";
exit(0); exit(0);
}
// Cleanup and free any unused memory. // Cleanup and free any unused memory.
FreeUnusedMemory(); FreeUnusedMemory();
@ -3042,6 +3045,7 @@ void LaunchStdinLoop(Config* config,
} }
case IpcId::Exit: { case IpcId::Exit: {
LOG_S(INFO) << "Exiting";
exit(0); exit(0);
break; break;
} }
@ -3087,8 +3091,8 @@ void LaunchStdinLoop(Config* config,
} }
default: { default: {
std::cerr << "[stdin] Unhandled IPC message " LOG_S(ERROR) << "Unhandled IPC message "
<< IpcIdToString(message->method_id) << std::endl; << IpcIdToString(message->method_id);
exit(1); exit(1);
} }
} }
@ -3131,8 +3135,8 @@ void LaunchStdoutThread(std::unordered_map<IpcId, Timer>* request_times,
} }
default: { default: {
std::cerr << "[stdout] Unhandled IPC message " LOG_S(FATAL) << "Exiting; unhandled IPC message "
<< IpcIdToString(message->method_id) << std::endl; << IpcIdToString(message->method_id);
exit(1); exit(1);
} }
} }

View File

@ -3,6 +3,7 @@
#include "platform.h" #include "platform.h"
#include <tinydir.h> #include <tinydir.h>
#include <loguru/loguru.hpp>
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
@ -333,7 +334,7 @@ void UpdateTestExpectation(const std::string& filename,
} }
void Fail(const std::string& message) { void Fail(const std::string& message) {
std::cerr << "Fatal error: " << message << std::endl; LOG_S(FATAL) << "Fatal error: " << message;
std::exit(1); std::exit(1);
} }