Log the program's final return when using @main_decorator.
This commit is contained in:
parent
f18f0fd2df
commit
e9d450029d
1 changed files with 4 additions and 2 deletions
|
@ -165,13 +165,15 @@ class LogHandlerContext:
|
||||||
def main_decorator(subject, *args, **kwargs):
|
def main_decorator(subject, *args, **kwargs):
|
||||||
'''
|
'''
|
||||||
Add this decorator to your application's main function to automatically
|
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 wrapper(main):
|
||||||
def wrapped(argv):
|
def wrapped(argv):
|
||||||
(context, argv) = main_log_context(argv, subject, *args, **kwargs)
|
(context, argv) = main_log_context(argv, subject, *args, **kwargs)
|
||||||
with context:
|
with context:
|
||||||
return main(argv)
|
status = main(argv)
|
||||||
|
log.info('Program finished, returned %s.', status)
|
||||||
|
return status
|
||||||
return wrapped
|
return wrapped
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue