Added --consoleLevel option. Default value is ERROR, not WARN.

This commit is contained in:
Daniel Wolf 2017-09-13 20:39:52 +02:00
parent ef245ce4ff
commit b2f52824b3
3 changed files with 30 additions and 11 deletions

View File

@ -151,9 +151,12 @@ The following command-line options can be helpful in special situations, especia
|===
| Option | Description
[[quiet]]
| `-q`, `--quiet`
| By default, Rhubarb Lip Sync writes a number of progress messages to `stderr`. If you're using it as part of a batch process, this may clutter your console. If you specify the `--quiet` flag, there won't be any output to `stderr` unless an error occurred.
You can combine this option with the <<consoleLevel,`consoleLevel`>> option to change the minimum event level that is printed to `stderr`.
| `--machineReadable`
a| This option is useful if you want to integrate Rhubarb Lip Sync with another (possibly graphical) application. All progress output to `stderr` will be in structured JSON format, allowing your program to parse the output and display a graphical progress bar or something similar.
@ -163,6 +166,8 @@ In this mode, each line printed to `stderr` will be an object in JSON format. Ev
* Event-specific structured data. For instance, a `"progress"` event contains the property `value` with a numeric value between 0.0 and 1.0.
* Property `log`: A log message describing the event, plus severity information. If you aren't interested in the structured data, you can display this as a fallback. For instance, a `"progress"` event with the structured information `"value": 0.69` may contain the following redundant log message: `"Progress: 69%"`.
You can combine this option with the <<consoleLevel,`consoleLevel`>> option. Note, however, that this only affects unstructured events of type `"log"` (not to be confused with the `log` property each event contains).
The following is an example output from a _successful_ run:
[source,json]
@ -192,11 +197,19 @@ Note that the output format <<Versioning,adheres to SemVer>>. That means that th
* Changes in JSON formatting, such as a re-ordering of properties or changes in whitespaces (except for line breaks -- every event will remain on a singe line.)
* Fewer or more events of type `"log"` or changes in the wording of log messages
[[consoleLevel]]
| `--consoleLevel` _<level>_
| Sets the log level for reporting to the console (`stderr`). Options: `trace`, `debug`, `info`, `warning`, `error`, `fatal`.
If <<quiet,`--quiet`>> is also specified, only events with the specified level or higher will be printed. Otherwise, a small number of essential events (startup, progress, etc.) will be printed even if their levels are below the specified value.
_Default value: ``error``_
| `--logFile` _<path>_
| Creates a log file with diagnostic information at the specified path.
|`--logLevel` _<level>_
| Sets the log level for the log file. Options: `trace`, `debug`, `info`, `warning`, `error`, `fatal`.
| Sets the log level for the log file. Only events with the specified level or higher will be logged. Options: `trace`, `debug`, `info`, `warning`, `error`, `fatal`.
_Default value: ``debug``_

View File

@ -4,6 +4,8 @@
* Full Unicode support. File names, dialog files, strings in exported files etc. should now be fully Unicode-compatible.
* Added `--machineReadable` command-line option to allow for better integration with other applications.
* Added `--consoleLevel` command-line option to control how much detail to log to the console (`stderr`).
* Unless specified using `--consoleLevel`, only errors and fatal errors are printed to the console. Previously, warnings were also printed.
## Version 1.6.0

View File

@ -93,8 +93,8 @@ ShapeSet getTargetShapeSet(const string& extendedShapesString) {
int main(int platformArgc, char *platformArgv[]) {
// Set up default logging so early errors are printed to stdout
const logging::Level minStderrLevel = logging::Level::Warn;
shared_ptr<logging::Sink> defaultSink = std::make_shared<NiceStderrSink>(minStderrLevel);
const logging::Level defaultMinStderrLevel = logging::Level::Error;
shared_ptr<logging::Sink> defaultSink = make_shared<NiceStderrSink>(defaultMinStderrLevel);
logging::addSink(defaultSink);
// Use UTF-8 throughout
@ -112,8 +112,9 @@ int main(int platformArgc, char *platformArgv[]) {
tclap::ValueArg<string> outputFileName("o", "output", "The output file path.", false, string(), "string", cmd);
auto logLevels = vector<logging::Level>(logging::LevelConverter::get().getValues());
tclap::ValuesConstraint<logging::Level> logLevelConstraint(logLevels);
tclap::ValueArg<logging::Level> logLevel("", "logLevel", "The minimum log level to log", false, logging::Level::Debug, &logLevelConstraint, cmd);
tclap::ValueArg<logging::Level> logLevel("", "logLevel", "The minimum log level that will be written to the log file", false, logging::Level::Debug, &logLevelConstraint, cmd);
tclap::ValueArg<string> logFileName("", "logFile", "The log file path.", false, string(), "string", cmd);
tclap::ValueArg<logging::Level> consoleLevel("", "consoleLevel", "The minimum log level that will be printed on the console (stderr)", false, defaultMinStderrLevel, &logLevelConstraint, cmd);
tclap::SwitchArg machineReadableMode("", "machineReadable", "Formats all output to stderr in a structured JSON format.", cmd, false);
tclap::SwitchArg quietMode("q", "quiet", "Suppresses all output to stderr except for warnings and error messages.", cmd, false);
tclap::ValueArg<int> maxThreadCount("", "threads", "The maximum number of worker threads to use.", false, getProcessorCoreCount(), "number", cmd);
@ -133,17 +134,20 @@ int main(int platformArgc, char *platformArgv[]) {
}
// Set up logging
// ... to stderr
if (quietMode.getValue()) {
logging::addSink(make_shared<QuietStderrSink>(consoleLevel.getValue()));
} else if (machineReadableMode.getValue()) {
logging::addSink(make_shared<MachineReadableStderrSink>(consoleLevel.getValue()));
} else {
logging::addSink(make_shared<NiceStderrSink>(consoleLevel.getValue()));
}
logging::removeSink(defaultSink);
// ... to log file
if (logFileName.isSet()) {
auto fileSink = createFileSink(path(logFileName.getValue()), logLevel.getValue());
logging::addSink(fileSink);
}
if (quietMode.getValue()) {
logging::removeSink(defaultSink);
logging::addSink(make_shared<QuietStderrSink>(minStderrLevel));
} else if (machineReadableMode.getValue()) {
logging::removeSink(defaultSink);
logging::addSink(make_shared<MachineReadableStderrSink>(minStderrLevel));
}
// Validate and transform command line arguments
if (maxThreadCount.getValue() < 1) {