Commit 25a4ae03 authored by Michael Ott's avatar Michael Ott
Browse files

If verbosity is not specified in the config file, don't open a sink for the file logger

parent a5e1dd30
......@@ -537,7 +537,7 @@ int main(int argc, char* const argv[]) {
cassandraSettings.ttl = stoul(optarg);
break;
case 'v':
settings.logLevelCmd = translateLogLevel(stoi(optarg));
settings.logLevelCmd = stoi(optarg);
break;
case 'd':
case 'D':
......@@ -556,10 +556,16 @@ int main(int argc, char* const argv[]) {
}
}
auto fileSink = setupFileLogger(pluginSettings.tempdir, std::string("collectagent"));
//set up logger to file
if (settings.logLevelFile >= 0) {
auto fileSink = setupFileLogger(pluginSettings.tempdir, std::string("dcdbpusher"));
fileSink->set_filter(boost::log::trivial::severity >= translateLogLevel(settings.logLevelFile));
}
//severity level may be overwritten (per option or config-file) --> set it according to globalSettings
fileSink->set_filter(boost::log::trivial::severity >= settings.logLevelFile);
cmdSink->set_filter(boost::log::trivial::severity >= settings.logLevelCmd);
if (settings.logLevelCmd >= 0) {
cmdSink->set_filter(boost::log::trivial::severity >= translateLogLevel(settings.logLevelCmd));
}
/*
* Catch SIGINT and SIGTERM signals to allow for proper server shutdowns.
......
......@@ -114,8 +114,8 @@ public:
bool daemonize = false;
bool statistics = false;
uint64_t threads = 24;
boost::log::trivial::severity_level logLevelFile = boost::log::trivial::trace;
boost::log::trivial::severity_level logLevelCmd = boost::log::trivial::info;
int logLevelFile = -1;
int logLevelCmd = 3;
analyticsSettings_t analyticsSettings;
restAPISettings_t restAPISettings;
pluginSettings_t pluginSettings;
......
......@@ -46,7 +46,7 @@ bool GlobalConfiguration::readConfig() {
} else if (boost::iequals(global.first, "validateConfig")) {
validateConfig = to_bool(global.second.data());
} else if (boost::iequals(global.first, "verbosity")) {
logLevelFile = translateLogLevel(stoi(global.second.data()));
logLevelFile = stoi(global.second.data());
} else if (boost::iequals(global.first, "statistics")) {
statistics = to_bool(global.second.data());
} else if (!readAdditionalValues(global)) {
......
......@@ -219,7 +219,7 @@ int main(int argc, char** argv) {
pluginSettings.mqttPrefix = optarg;
break;
case 'v':
globalSettings.logLevelCmd = translateLogLevel(stoi(optarg));
globalSettings.logLevelCmd = stoi(optarg);
break;
case 'd':
globalSettings.daemonize = 1;
......@@ -244,11 +244,15 @@ int main(int argc, char** argv) {
//we now should know where the writable tempdir is
//set up logger to file
auto fileSink = setupFileLogger(pluginSettings.tempdir, std::string("dcdbpusher"));
if (globalSettings.logLevelFile >= 0) {
auto fileSink = setupFileLogger(pluginSettings.tempdir, std::string("dcdbpusher"));
fileSink->set_filter(boost::log::trivial::severity >= translateLogLevel(globalSettings.logLevelFile));
}
//severity level may be overwritten (per option or config-file) --> set it according to globalSettings
fileSink->set_filter(boost::log::trivial::severity >= globalSettings.logLevelFile);
cmdSink->set_filter(boost::log::trivial::severity >= globalSettings.logLevelCmd);
if (globalSettings.logLevelCmd >= 0) {
cmdSink->set_filter(boost::log::trivial::severity >= translateLogLevel(globalSettings.logLevelCmd));
}
LOG(info) << "Logging setup complete";
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment