I would like to extend the existing logging.LEVEL
mechanics so that I have the option of switching between different logging levels such as DEBUG
, INFO
, ERROR
etc. but also define a depth
for each of the levels.
For example, let's assume that the logging level is set to logging.DEBUG
. All of the log.DEBUG()
calls will be visible.
log.debug('Limit event has occurred.')
So I get:
[2016-10-08 10:07:29,807] <__main__> {myApp:test_condition_info:93} (DEBUG) Limit event has occurred.
What I am after, is passing an extra depth level to the log.debug()
call so that I can control how much of detail is printed in the DEBUG
message, not entirely enabling or disabling the DEBUG level but controlling how much information the debug message will carry. So in all cases we see the debug message but in some instances, it is less detailed and on some occasions more information is included.
For example:
log.debug('Limit event has occurred.', verbosity=1)
log.debug('The following user has caused the limit event: %s' % (user), verbosity=3)
log.debug('The following files have been affected: %s' % [list_of_files], verbosity=7)
So when the logging level is set to DEBUG
and the global verbosity is set to GLOBAL_VERBOSITY=1
we will get this:
[2016-10-08 10:07:29,807] <__main__> {myApp:test_condition_info:93} (DEBUG) Limit event has occurred.
And if the global verbosity is set to GLOBAL_VERBOSITY=4
we will get this:
[2016-10-08 10:07:29,807] <__main__> {myApp:test_condition_info:93} (DEBUG) Limit event has occurred.
[2016-10-08 10:07:29,807] <__main__> {myApp:test_condition_info:93} (DEBUG) The following user has caused the limit event: xpr
And if the global verbosity is set to GLOBAL_VERBOSITY=9
we will get all of the details:
[2016-10-08 10:07:29,807] <__main__> {myApp:test_condition_info:93} (DEBUG) Limit event has occurred.
[2016-10-08 10:07:29,807] <__main__> {myApp:test_condition_info:93} (DEBUG) The following user has caused the limit event: xpr
[2016-10-08 10:07:29,807] <__main__> {myApp:test_condition_info:93} (DEBUG) The following files have been affected: ['inside.ini', 'render.so']
How should I approach this problem?