File tree 5 files changed +30
-2
lines changed
5 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).
5
5
6
6
The format is based on [ Keep a Changelog] ( http://keepachangelog.com/ ) .
7
7
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
+
8
14
## 4.2.4 - 2022-04-26
9
15
10
16
### Update
Original file line number Diff line number Diff line change 10
10
from sap .cf_logging .record .request_log_record import RequestWebRecord
11
11
from sap .cf_logging .record .simple_log_record import SimpleLogRecord
12
12
13
- __version__ = '4.2.4 '
13
+ __version__ = '4.2.5 '
14
14
15
15
_SETUP_DONE = False
16
16
FRAMEWORK = None
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ def format(self):
75
75
'msg' : self .getMessage (),
76
76
})
77
77
78
- if self .levelno == logging . ERROR and self . exc_info :
78
+ if self .exc_info :
79
79
stacktrace = '' .join (traceback .format_exception (* self .exc_info ))
80
80
stacktrace = format_stacktrace (stacktrace )
81
81
record ['stacktrace' ] = stacktrace .split ('\n ' )
Original file line number Diff line number Diff line change 38
38
'Programming Language :: Python :: 3.5' ,
39
39
'Programming Language :: Python :: 3.6' ,
40
40
'Programming Language :: Python :: 3.8' ,
41
+ 'Programming Language :: Python :: 3.9' ,
42
+ 'Programming Language :: Python :: 3.10' ,
43
+ 'Programming Language :: Python :: 3.11' ,
41
44
'Topic :: Software Development :: Libraries :: Python Modules' ,
42
45
'Topic :: Software Development' ,
43
46
'Topic :: System :: Logging' ,
Original file line number Diff line number Diff line change @@ -68,6 +68,25 @@ def test_exception_stacktrace():
68
68
69
69
assert error == {}
70
70
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
+
71
90
72
91
def test_custom_fields_set ():
73
92
""" Test custom fields are set up """
You can’t perform that action at this time.
0 commit comments