Skip to content

Commit 697ea5a

Browse files
committed
Update README with info about changes to version 5
Document the changes made with regards to logging the traceback.
1 parent e02bf5e commit 697ea5a

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

README.md

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ All features can be fully configured from the configuration file.
1717

1818
**NOTE:** only python 3 is supported
1919

20-
:warning: **Version 3.x.x BREAKING CHANGES** see [Breaking Changes](#version-3xx-breaking-changes)
20+
:warning: **Version 5.x.x BREAKING CHANGES** see [Breaking Changes](#version-5xx-breaking-changes)
2121

2222
## Table of content
2323

@@ -67,7 +67,9 @@ All features can be fully configured from the configuration file.
6767
- [Case 7. Add all Log Extra as Dictionary to the Standard Formatter (including Django log extra)](#case-7-add-all-log-extra-as-dictionary-to-the-standard-formatter-including-django-log-extra)
6868
- [Case 8. Add Specific Log Extra to the Standard Formatter](#case-8-add-specific-log-extra-to-the-standard-formatter)
6969
- [Case 9. Django add request info to all log records](#case-9-django-add-request-info-to-all-log-records)
70+
- [Case 10. Add stack traces to log records](#case-10-add-stack-traces-to-log-records)
7071
- [Breaking Changes](#breaking-changes)
72+
- [Version 5.x.x Breaking Changes](#version-5xx-breaking-changes)
7173
- [Version 4.x.x Breaking Changes](#version-4xx-breaking-changes)
7274
- [Version 3.x.x Breaking Changes](#version-3xx-breaking-changes)
7375
- [Version 2.x.x Breaking Changes](#version-2xx-breaking-changes)
@@ -273,7 +275,7 @@ For more information on Pyramid Tweens see [Registering Tween](https://docs.pylo
273275

274276
## JSON Formatter
275277

276-
**JsonFormatter** is a python logging formatter that transform the log output into a json object.
278+
**JsonFormatter** is a python logging formatter that transforms the log output into a json object.
277279

278280
JSON log format is quite useful especially when the logs are sent to **LogStash**.
279281

@@ -1368,8 +1370,44 @@ handlers:
13681370
- request_fields
13691371
```
13701372
1373+
### Case 10. Add stack traces to log records
1374+
1375+
If you want to embed the stack trace of either an Exception or a log entry in general, you can do so with following additions to the logging call:
1376+
1377+
```python
1378+
import sys
1379+
1380+
logger.debug('My log with stack info', stack_info=True)
1381+
logger.critical('Exception happened', exc_info=sys.exc_info())
1382+
```
1383+
1384+
This will make the stack info available for the formatter. It can be used for instance like follows:
1385+
1386+
```yaml
1387+
[...]
1388+
formatters:
1389+
json:
1390+
(): logging_utilities.formatters.json_formatter.JsonFormatter
1391+
fmt:
1392+
error:
1393+
stack_trace: exc_text
1394+
stack_info: stack_info
1395+
time: asctime
1396+
level: levelname
1397+
logger: name
1398+
module: module
1399+
message: message
1400+
request:
1401+
path: request.path
1402+
method: request.method
1403+
```
1404+
13711405
## Breaking Changes
13721406
1407+
### Version 5.x.x Breaking Changes
1408+
1409+
Previously, the fields `exc_text` and `stack_info` were always added to the log message if they existed. This behavior is slightly changed: instead of adding them to the message in any case, they were added to the record so that they can be configured via the `fmt` field in the logging configuration as described in [#case-10-add-stack-traces-to-log-records].
1410+
13731411
### Version 4.x.x Breaking Changes
13741412

13751413
From version 3.x.x to version 4.x.x there is the following breaking change:

0 commit comments

Comments
 (0)