Show full error logs at "--verbosity 0" so you can see command output without upping the verbosity level.
This commit is contained in:
parent
e63e2e0852
commit
55ebfdda39
4 changed files with 16 additions and 7 deletions
4
NEWS
4
NEWS
|
@ -1,3 +1,7 @@
|
||||||
|
1.4.13
|
||||||
|
* Show full error logs at "--verbosity 0" so you can see command output without upping the
|
||||||
|
verbosity level.
|
||||||
|
|
||||||
1.4.12
|
1.4.12
|
||||||
* #247: With "borgmatic check", consider Borg warnings as errors.
|
* #247: With "borgmatic check", consider Borg warnings as errors.
|
||||||
* Dial back the display of inline error logs a bit, so failed command output doesn't appear
|
* Dial back the display of inline error logs a bit, so failed command output doesn't appear
|
||||||
|
|
|
@ -365,14 +365,16 @@ def load_configurations(config_filenames):
|
||||||
return (configs, logs)
|
return (configs, logs)
|
||||||
|
|
||||||
|
|
||||||
def log_record(**kwargs):
|
def log_record(suppress_log=False, **kwargs):
|
||||||
'''
|
'''
|
||||||
Create a log record based on the given makeLogRecord() arguments, one of which must be
|
Create a log record based on the given makeLogRecord() arguments, one of which must be
|
||||||
named "levelno". Log the record and return it.
|
named "levelno". Log the record (unless suppress log is set) and return it.
|
||||||
'''
|
'''
|
||||||
record = logging.makeLogRecord(kwargs)
|
record = logging.makeLogRecord(kwargs)
|
||||||
logger.handle(record)
|
if suppress_log:
|
||||||
|
return record
|
||||||
|
|
||||||
|
logger.handle(record)
|
||||||
return record
|
return record
|
||||||
|
|
||||||
|
|
||||||
|
@ -390,8 +392,11 @@ def make_error_log_records(message, error=None):
|
||||||
except CalledProcessError as error:
|
except CalledProcessError as error:
|
||||||
yield log_record(levelno=logging.CRITICAL, levelname='CRITICAL', msg=message)
|
yield log_record(levelno=logging.CRITICAL, levelname='CRITICAL', msg=message)
|
||||||
if error.output:
|
if error.output:
|
||||||
yield logging.makeLogRecord(
|
yield log_record(
|
||||||
dict(levelno=logging.CRITICAL, levelname='CRITICAL', msg=error.output)
|
levelno=logging.CRITICAL,
|
||||||
|
levelname='CRITICAL',
|
||||||
|
msg=error.output,
|
||||||
|
suppress_log=bool(logger.getEffectiveLevel() < logging.WARNING),
|
||||||
)
|
)
|
||||||
yield log_record(levelno=logging.CRITICAL, levelname='CRITICAL', msg=error)
|
yield log_record(levelno=logging.CRITICAL, levelname='CRITICAL', msg=error)
|
||||||
except (ValueError, OSError) as error:
|
except (ValueError, OSError) as error:
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -1,6 +1,6 @@
|
||||||
from setuptools import find_packages, setup
|
from setuptools import find_packages, setup
|
||||||
|
|
||||||
VERSION = '1.4.12'
|
VERSION = '1.4.13'
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
|
|
|
@ -129,7 +129,7 @@ def test_make_error_log_records_generates_output_logs_for_message_only():
|
||||||
|
|
||||||
def test_make_error_log_records_generates_output_logs_for_called_process_error():
|
def test_make_error_log_records_generates_output_logs_for_called_process_error():
|
||||||
flexmock(module).should_receive('log_record').replace_with(dict)
|
flexmock(module).should_receive('log_record').replace_with(dict)
|
||||||
flexmock(module.logging).should_receive('makeLogRecord').replace_with(dict)
|
flexmock(module.logger).should_receive('getEffectiveLevel').and_return(logging.WARNING)
|
||||||
|
|
||||||
logs = tuple(
|
logs = tuple(
|
||||||
module.make_error_log_records(
|
module.make_error_log_records(
|
||||||
|
|
Loading…
Reference in a new issue