Add option log_return_value.
This commit is contained in:
parent
531424c8c1
commit
87fbede7d5
1 changed files with 3 additions and 2 deletions
|
@ -220,7 +220,7 @@ def get_level_by_argv(argv):
|
||||||
|
|
||||||
return (argv, level)
|
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
|
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:
|
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:
|
with context:
|
||||||
status = main(argv)
|
status = main(argv)
|
||||||
log.info('Program finished, returned %s.', status)
|
if log_return_value:
|
||||||
|
log.info('Program finished, returned %s.', status)
|
||||||
return status
|
return status
|
||||||
return wrapped
|
return wrapped
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
Loading…
Reference in a new issue