Commit 305c7b01 authored by Micha Mueller's avatar Micha Mueller
Browse files

Invert meaning of verbosity level (now 0 only fatal, 5 all)

parent 6bd91d19
......@@ -40,7 +40,7 @@ global {
mqttBroker localhost:1883
mqttprefix /00112233445566778899AABB0000
threads 24
verbosity 0
verbosity 5
daemonize false
tempdir ./../testDir/
}
......@@ -66,7 +66,7 @@ Explanation of the values:
|   mqttBroker | Define address and port of the MQTT-broker which collects the messages (sensor values) send by dcdbpusher.
|   mqttprefix | To not rewrite a full MQTT-topic for every sensor one can specify here a consistend prefix.
|   threads | Specify how many threads should be created to handle the sensors async. Default value of threads is 1. Note that the MQTTPusher always starts an extra thread. So the actual number of started threads is always one more than defined here. Specifying not enough threads can result in a delay for some sensors until they are read.
|   verbosity | Level of detail in the logfile (dcdb.log). Set to a value between 0 (all log-messages, default) and 5 (only fatal messages). NOTE: level of verbosity for the command-line log can be set via the -v flag independently when invoking dcdbpusher.
|   verbosity | Level of detail in the logfile (dcdb.log). Set to a value between 5 (all log-messages, default) and 0 (only fatal messages). NOTE: level of verbosity for the command-line log can be set via the -v flag independently when invoking dcdbpusher.
|   daemonize | Set to 'true' if dcdbpusher should run detached as daemon. Default is false.
|   tempdir | One can specify a writeable directory where dcdbpusher can write its temporary and logging files to. Default is the current (' ./ ' ) directory.
| | |
......
......@@ -2,7 +2,7 @@ global {
mqttBroker localhost:1883
mqttprefix /00112233445566778899AABB0000
threads 24
verbosity 0
verbosity 5
daemonize false
tempdir .
}
......
......@@ -88,11 +88,44 @@ void printSyntax()
cout << endl;
cout << " -d Daemonize" << endl;
cout << " -v Set verbosity of output." << endl
<< " Can be number between 0 (all output) and 5 (only fatal messages)" << endl;
<< " Can be a number between 5 (all output) and 0 (only fatal messages)." << endl
<< " Default level is 3 (info)" << endl;
cout << " -h This help page" << endl;
cout << endl;
}
/*
* Inverts the given severity level.
* trace <=> fatal
* debug <=> error
* info <=> warning
*/
boost::log::trivial::severity_level invertLogLevel(boost::log::trivial::severity_level logLevel) {
switch (logLevel) {
case boost::log::trivial::trace:
return boost::log::trivial::fatal;
break;
case boost::log::trivial::debug:
return boost::log::trivial::error;
break;
case boost::log::trivial::info:
return boost::log::trivial::warning;
break;
case boost::log::trivial::warning:
return boost::log::trivial::info;
break;
case boost::log::trivial::error:
return boost::log::trivial::debug;
break;
case boost::log::trivial::fatal:
return boost::log::trivial::trace;
break;
default:
return boost::log::trivial::info;
break;
}
}
int main(int argc, char** argv) {
if (argc <= 1) {
cout << "Please specify a path to the config-directory" << endl << endl;
......@@ -211,6 +244,10 @@ int main(int argc, char** argv) {
boost::log::keywords::auto_flush = true
);
//invert log level, because 0 casts to trace (and 5 to fatal) but we want the meaning to be the other way round (0 equals fatal, 5 trace)
globalSettings.logLevelCmd = invertLogLevel(globalSettings.logLevelCmd);
globalSettings.logLevelFile = invertLogLevel(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);
......
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