Closed drdaeman closed 6 years ago
Hi @drdaeman, thanks for reporting this issue. I wholeheartedly agree with you that your example is a valid and reasonable way to use a standard logging library. I am able to send the above debug statement properly formatted using the LogDNAHandler. Could you try my configuration? I believe there may be an issue with setting the default level to a low enough priority (DEBUG). Please do let me know if the following code does not work for you and we can further diagnose what the problem may be.
import logging
from logdna import LogDNAHandler
key = '<YOUR API KEY HERE>'
log = logging.getLogger('logdna')
# Should set level to lowest priority to send debug statements
log.setLevel(logging.DEBUG)
test = LogDNAHandler(key, { 'hostname': 'pytest1', 'index_meta': True })
log.addHandler(test)
username = "Me"
status = "working"
log.debug("User %s is now %s", username, status)
Hi @drdaeman,
I hope you got a chance to try out my suggestion above. I'm closing this issue now, since I am not able to reproduce it. I would be glad to reopen it if you continue experiencing issues and we can debug further. Thanks for keeping up with this module!
Hi. I've tried to add LogDNAHandler to logging configuration of some existing project and noticed that it started raise a lot of exceptions. If the record was logged with non-keyword arguments, like
Then logger would fail with
TypeError: tuple indices must be integers or slices, not str
. Still, that's a valid and reasonably common way to use standard library logging.This happens because:
And
record["args"]
is a list, e.g.:I know, the structured logging and keyword arguments are the way to go, but legacy logging code and quick hacks (to print some debug data quick) are reality.
Also, I'm not sure it is a good idea to use
record.args
at all - in standard library'sLogRecord
, its sole purpose is to convert frommsg
tomessage
. Maybe this logic should be put behind someoptions["use_args"]
flag.