Logging Levels
Logging is used for informational or debugging purposes.
There are 6 levels of logging that you can utilize.
- CRITICAL
- ERROR
- WARNING
- INFO
- DEBUG
- NOTSET
Logging Setup
import logging logging.basicConfig(filename='game.log', level=logging.DEBUG)
Usage
Inside the parentheses you type in the message string you need to logged.
This should log the starting position of the game. ... monster, door, player['location'] = get_locations() logging.info('monster: {}; door: {}; player: {}'.format( monster, door, player['location'])) ...
After you run this, nothing should change in your app or your console.
However, if you open the logfile game.log you’ll find all the loggings in there.