Allow --operatornotify-level to act as opt in without both flags.
This commit is contained in:
parent
bfb06d46c9
commit
cb4cef9339
1 changed files with 9 additions and 9 deletions
|
@ -189,22 +189,22 @@ def main_log_context(argv, subject, *args, **kwargs):
|
||||||
# Do not modiy this code without considering both effects.
|
# Do not modiy this code without considering both effects.
|
||||||
argv = ['--operatornotify-level' if arg == '--operatornotify_level' else arg for arg in argv]
|
argv = ['--operatornotify-level' if arg == '--operatornotify_level' else arg for arg in argv]
|
||||||
|
|
||||||
if '--operatornotify' in argv:
|
level = None
|
||||||
argv.remove('--operatornotify')
|
|
||||||
else:
|
|
||||||
return (contextlib.nullcontext(), argv)
|
|
||||||
|
|
||||||
if '--operatornotify-level' in argv:
|
if '--operatornotify-level' in argv:
|
||||||
level = argv.pop(argv.index('--operatornotify-level') + 1)
|
level = argv.pop(argv.index('--operatornotify-level') + 1)
|
||||||
try:
|
try:
|
||||||
level = int(level)
|
level = int(level)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
level = vlogging.get_level_by_name(level)
|
||||||
argv.remove('--operatornotify-level')
|
argv.remove('--operatornotify-level')
|
||||||
else:
|
|
||||||
level = vlogging.WARNING
|
|
||||||
|
|
||||||
level = vlogging.get_level_by_name(level)
|
if '--operatornotify' in argv:
|
||||||
|
if level is None:
|
||||||
|
level = vlogging.WARNING
|
||||||
|
argv.remove('--operatornotify')
|
||||||
|
|
||||||
|
if level is None:
|
||||||
|
return (contextlib.nullcontext(), argv)
|
||||||
|
|
||||||
log = vlogging.getLogger()
|
log = vlogging.getLogger()
|
||||||
handler = LogHandler(subject, *args, **kwargs)
|
handler = LogHandler(subject, *args, **kwargs)
|
||||||
|
|
Loading…
Reference in a new issue