You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
python_log_indenter is very useful and what I was looking for. I have found one small thing.
I have (%(filename)s:%(funcName)s:%(lineno)s) in the formatted string that I am using for logging.
When using IndentedLoggerAdapter() the file location shows pli.py instead of the actual location that has the logging statement. I don't know the inner workings of Python logging well enough to know if there is a way to pass that location information on to the actual logging function.
The text was updated successfully, but these errors were encountered:
Yeah, that's a challange I hadn't thought fo at the time, though it's a common issue with things like this.
Later in a different program I made this function...
def get_line_no(offset=0, sep='\n'):
try:
raise NotImplementedError()
except NotImplementedError:
formatted_lines = traceback.format_stack()
tmp_stack = []
start = False
for line in formatted_lines:
if 'unittest' in line.lower() or 'django' in line.lower():
start = True
continue
if '\who_helpers\test_helpers.py' in line:
continue
if not start:
continue
tmp_stack.append(line)
return ''.join(tmp_stack)
it's not a perfect answer to your issue, but it might give you a starting point to addressing it somehow.
Offhand I'm not sure how to "fix" it automatically in the code. I will have to dive a bit deeper to figure out how the logging system does the lookups for things like line numbers. it might come down to adding another variable (like 'line_num" that takes this into account.
python_log_indenter
is very useful and what I was looking for. I have found one small thing.I have
(%(filename)s:%(funcName)s:%(lineno)s)
in the formatted string that I am using for logging.When using
IndentedLoggerAdapter()
the file location shows pli.py instead of the actual location that has the logging statement. I don't know the inner workings of Python logging well enough to know if there is a way to pass that location information on to the actual logging function.The text was updated successfully, but these errors were encountered: