From e9d450029d8d2e46115f631241a3e7c9472a5ab7 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 4 Jul 2021 15:44:50 -0700 Subject: [PATCH] Log the program's final return when using @main_decorator. --- voussoirkit/operatornotify.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/voussoirkit/operatornotify.py b/voussoirkit/operatornotify.py index 4cda2e5..21ece2a 100644 --- a/voussoirkit/operatornotify.py +++ b/voussoirkit/operatornotify.py @@ -165,13 +165,15 @@ class LogHandlerContext: def main_decorator(subject, *args, **kwargs): ''' Add this decorator to your application's main function to automatically - wrap it in a main_log_context. + wrap it in a main_log_context and log the final return value. ''' def wrapper(main): def wrapped(argv): (context, argv) = main_log_context(argv, subject, *args, **kwargs) with context: - return main(argv) + status = main(argv) + log.info('Program finished, returned %s.', status) + return status return wrapped return wrapper