File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,6 +5,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).
55
66The format is based on [ Keep a Changelog] ( http://keepachangelog.com/ ) .
77
8+ ## 4.2.5 - 2023-07-28
9+
10+ ### Fixed
11+
12+ - Include stacktrace also for non-error log level if exc_info is present
13+
814## 4.2.4 - 2022-04-26
915
1016### Update
Original file line number Diff line number Diff line change 1010from sap .cf_logging .record .request_log_record import RequestWebRecord
1111from sap .cf_logging .record .simple_log_record import SimpleLogRecord
1212
13- __version__ = '4.2.4 '
13+ __version__ = '4.2.5 '
1414
1515_SETUP_DONE = False
1616FRAMEWORK = None
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ def format(self):
7575 'msg' : self .getMessage (),
7676 })
7777
78- if self .levelno == logging . ERROR and self . exc_info :
78+ if self .exc_info :
7979 stacktrace = '' .join (traceback .format_exception (* self .exc_info ))
8080 stacktrace = format_stacktrace (stacktrace )
8181 record ['stacktrace' ] = stacktrace .split ('\n ' )
Original file line number Diff line number Diff line change 3838 'Programming Language :: Python :: 3.5' ,
3939 'Programming Language :: Python :: 3.6' ,
4040 'Programming Language :: Python :: 3.8' ,
41+ 'Programming Language :: Python :: 3.9' ,
42+ 'Programming Language :: Python :: 3.10' ,
43+ 'Programming Language :: Python :: 3.11' ,
4144 'Topic :: Software Development :: Libraries :: Python Modules' ,
4245 'Topic :: Software Development' ,
4346 'Topic :: System :: Logging' ,
Original file line number Diff line number Diff line change @@ -68,6 +68,25 @@ def test_exception_stacktrace():
6868
6969 assert error == {}
7070 assert 'ZeroDivisionError' in str (log_json ['stacktrace' ])
71+ assert 'ZeroDivisionError' in log_json ["msg" ]
72+
73+
74+ def test_exception_stacktrace_info_level ():
75+ """ Test exception stacktrace is logged """
76+ cf_logging .init (level = logging .DEBUG )
77+ logger , stream = config_logger ('cli.test' )
78+
79+ try :
80+ return 1 / 0
81+ except ZeroDivisionError as exc :
82+ logger .info ('zero division error' , exc_info = exc )
83+ log_json = JSONDecoder ().decode (stream .getvalue ())
84+ _ , error = JsonValidator (JOB_LOG_SCHEMA ).validate (log_json )
85+
86+ assert error == {}
87+ assert 'ZeroDivisionError' in str (log_json ['stacktrace' ])
88+ assert 'ZeroDivisionError' in log_json ["msg" ]
89+
7190
7291def test_custom_fields_set ():
7392 """ Test custom fields are set up """
You can’t perform that action at this time.
0 commit comments