I followed the advice of the django docs, and use logging like this:
import logging
logger = logging.getLogger(__name__)
def today(...):
logger.info('Sun is shining, the weather is sweet')
With my current configuration, the output looks like this:
2016-08-11 14:54:06 mylib.foo.today: INFO Sun is shining, the weather is sweet
Unfortunately some libraries which I can't modify use logging like this:
import logging
def third_party(...):
logging.info('Make you want to move your dancing feet')
The output unfortunately looks like this:
2016-08-09 08:28:04 root.third_party: INFO Make you want to move your dancing feet
I want to see this:
2016-08-09 08:28:04 other_lib.some_file.third_party: INFO Make you want to move your dancing feet
Difference:
root.third_party ==> other_lib.some_file.third_party
I want to see the long version (not root
) if code uses logging.info()
instead of logger.info()
Update
This is not a duplicate of Elegant setup of Python logging in Django, since the solution of it is:
Start of quote
In each module, I define a logger using
logger = logging.getLogger(__name__)
End of quote.
No, I won't modify third-party-code which uses logging.info()
instead of logger.info()
.
Follow Up Question
Avoid logger=logging.getLogger(__name__)
without loosing way to filter logs