Control logging via command line and environment variables

Nheko is very chatty in its log output, generating log noise (which
complicates diagnostics) and needless disk writes (which affect power
consumption and SSD life).  This patch introduces command line options
and environment variables to control log levels and output type.

The old --debug command line option still works, at least for now.
It is overridden by the new command line options when they are used.

Partially addresses #665.
This commit is contained in:
Forest 2022-08-23 12:47:52 -07:00
parent 9b751fe6d8
commit 80f7683a57
4 changed files with 96 additions and 22 deletions

View file

@ -31,7 +31,27 @@ Displays help including Qt specific options.
Displays version information.
*--debug*::
Enables debug output.
Alias for _--log-level trace_.
*-l*, *--log-level* _<level>_::
Set the global log level, or a comma-separated list of _<component>=<level>_
pairs, or both. For example, to set the default log level to _warn_ but
disable logging for the _ui_ component, pass _warn,ui=off_.
+
levels: _trace_ _debug_ _info_ _warning_ _error_ _critical_ _off_
+
components: _crypto_ _db_ _mtx_ _net_ _qml_ _ui_
+
Log levels can also be set in the NHEKO_LOG_LEVEL environment variable, using
the same syntax. It will be overridden by this command line option.
*-L*, *--log-type* _<type>_::
Set the log output type. A comma-separated list is allowed. The default is _file,stderr_.
+
types: _file_ _stderr_ _none_
+
The log type can also be set in the NHEKO_LOG_TYPE environment variable,
which will be overridden by this command line option.
*-p* _<profile>_, *--profile* _<profile>_::
Creates a unique profile, which allows you to log into several accounts at the