borgbackup / borgbackup/borg

allow a combination of BORG_LOGGING_CONF and commandline log-level

Open
#3,562 6 comments 0 reactions 0 assignees View on GitHub
cli
Dominant language
Python
Stars
13.7k
Forks
875
Avg merge
11h 15m
Merged PRs (30d)
192

Description

Currently the commandline options that set the log-level (``--verbose``, ``--debug`` etc.) are ignored, if a logging config is specified via ``BORG_LOGGING_CONF``.

I believe it would make sense to be able to override the log level of the file-based config with the commandline-options.

The easiest way to obtain that would be to change the argparse default to ``None`` and set the level of the root logger in the "config file branch" if level is different from None. (And default to `warning` otherwise.)
https://github.com/borgbackup/borg/blob/1.1.4/src/borg/logger.py#L72

However maybe it would be better to only change the level of the _stream logger_ if a logging config is used? That way one could define a logging config like below, that logs both to a logfile and stderr and the commandline log-level would only affect the stderr output...

```
[loggers]
keys=root

[logger_root]
handlers=stderr,file
level=NOTSET

[handlers]
keys=file,stderr

[handler_file]
class=FileHandler
level=INFO
formatter=file
args=('/var/log/borgbackup.log',)

[handler_stderr]
class=StreamHandler
formatter=stream
level=NOTSET
args=(sys.stderr,)

[formatters]
keys=stream,file

# name: module, e.g. borg.archiver
[formatter_stream]
format=%(levelname).1s %(message)s

[formatter_file]
format=%(asctime)s %(levelname).1s %(message)s
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.