From 87fbede7d5444c42144be8fae9030de9c6f3fbae Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 9 Oct 2021 17:56:31 -0700 Subject: [PATCH] Add option log_return_value. --- voussoirkit/operatornotify.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/voussoirkit/operatornotify.py b/voussoirkit/operatornotify.py index 7cdc1ce..266d208 100644 --- a/voussoirkit/operatornotify.py +++ b/voussoirkit/operatornotify.py @@ -220,7 +220,7 @@ def get_level_by_argv(argv): return (argv, level) -def main_decorator(subject, **kwargs): +def main_decorator(subject, *, log_return_value=True, **kwargs): ''' Add this decorator to your application's main function to automatically wrap it in a main_log_context and log the final return value. For example: @@ -255,7 +255,8 @@ def main_decorator(subject, **kwargs): with context: status = main(argv) - log.info('Program finished, returned %s.', status) + if log_return_value: + log.info('Program finished, returned %s.', status) return status return wrapped return wrapper