UnboundLocalError: local variable 'now' referenced before assignment in LogstashFormatterV1
Closed this issue · 0 comments
mark-adams commented
Looks like there is a small issue with indentation in LogstashFormatterV1 where the variable "now" is only declared if 'exc_text' in fields and not fields['exc_text']
. However the next line, which is outside of the preceding "if" block, always makes use of now creating the following error.
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 851, in emit
msg = self.format(record)
File "/usr/lib/python2.7/logging/__init__.py", line 724, in format
return fmt.format(record)
File "{{redacted}}/__init__.py", line 143, in format
base_log = {'@timestamp': now.strftime("%Y-%m-%dT%H:%M:%S") + ".%03d" % (now.microsecond / 1000) + "Z",
UnboundLocalError: local variable 'now' referenced before assignment