1
0
Fork 0

don't log client tool errors to Windows event log

This commit is contained in:
jsteemann 2016-07-06 12:30:02 +02:00
parent 507c7ea232
commit a7c59c60f3
3 changed files with 17 additions and 2 deletions

View File

@ -108,7 +108,17 @@ LONG CALLBACK unhandledExceptionHandler(EXCEPTION_POINTERS* e) {
ArangoGlobalContext* ArangoGlobalContext::CONTEXT = nullptr;
ArangoGlobalContext::ArangoGlobalContext(int argc, char* argv[])
: _binaryName(TRI_BinaryName(argv[0])), _ret(EXIT_FAILURE) {
: _binaryName(TRI_BinaryName(argv[0])), _ret(EXIT_FAILURE), _useEventLog(true) {
static char const* serverName = "arangod";
if (_binaryName.size() < strlen(serverName) ||
_binaryName.substr(_binaryName.size() - strlen(serverName)) != serverName) {
// turn off event-logging for all binaries except arangod
// the reason is that all other tools are client tools that will directly
// print all errors so the user can handle them
_useEventLog = false;
}
ADB_WindowsEntryFunction();
#ifdef _WIN32

View File

@ -43,10 +43,12 @@ class ArangoGlobalContext {
void unmaskStandardSignals();
void runStartupChecks();
void tempPathAvailable();
bool useEventLog() { return _useEventLog; }
private:
std::string _binaryName;
int _ret;
bool _useEventLog;
};
}

View File

@ -24,6 +24,7 @@
#include "Logger.h"
#include "Basics/ArangoGlobalContext.h"
#include "Basics/ConditionLocker.h"
#include "Basics/Exceptions.h"
#include "Basics/MutexLocker.h"
@ -204,7 +205,9 @@ void Logger::log(char const* function, char const* file, long int line,
std::string const& message) {
#ifdef _WIN32
if (level == LogLevel::FATAL || level == LogLevel::ERR) {
TRI_LogWindowsEventlog(function, file, line, message);
if (ArangoGlobalContext::CONTEXT->useEventLog()) {
TRI_LogWindowsEventlog(function, file, line, message);
}
}
#endif