Skip to content

Commit 139fd35

Browse files
committed
Don't incude exception information unless an exception exists
1 parent ca66a1a commit 139fd35

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

json_logging/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ def format(self, record):
252252
"logger": record.name,
253253
"thread": record.threadName,
254254
"level": record.levelname,
255+
"line_no": record.lineno,
255256
"module": record.module,
256257
"msg": record.getMessage(),
257258
}
@@ -305,7 +306,7 @@ def format(self, record):
305306
if hasattr(record, 'props'):
306307
json_log_object.update(record.props)
307308

308-
if hasattr(record, 'exc_info') or hasattr(record, 'exc_text'):
309+
if record.exc_info or record.exc_text:
309310
json_log_object.update(self.get_exc_fields(record))
310311

311312
return JSON_SERIALIZER(json_log_object)

0 commit comments

Comments
 (0)