Skip to content
Snippets Groups Projects
Commit da2661c5 authored by Dominik Zobel's avatar Dominik Zobel
Browse files

Make very minimal logger minimal again

parent d24eb7e2
No related branches found
No related tags found
1 merge request!56Debugging Strategies lecture notes
......@@ -665,7 +665,7 @@ If you also managed to solve the bug
# Debugging broken code
## Logging
## Logging (1/2)
_Make debugging easier with proper logging_
......@@ -673,14 +673,26 @@ _Make debugging easier with proper logging_
```Python
import logging
logging.basicConfig(filename='output.log', level=logging.WARNING,
datefmt='%H:%M:%S', format='[%(asctime)s] %(levelname)-8s in ' \
+ '%(pathname)s:%(lineno)d %(message)s')
logging.warning('Example warning message')
logging.error('Example error message')
```
## Logging (2/2) {.leftalign}
Optionally: Adjust the logger to your needs
- Set output parameters
- Set log level and formatting
Example:
```python
logging.basicConfig(filename='output.log', level=logging.WARNING,
datefmt='%H:%M:%S', format='[%(asctime)s] %(levelname)-8s in ' \
+ '%(pathname)s:%(lineno)d %(message)s')
```
## Hands-On! (~10min) {.handson .leftalign}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment