1. How to use¶
The following examples assume a log format of
[%(name)s - %(level)s] %(message)s
You may want to read the Annex: Quick survival guide with the logging module to achieve this.
1.1. Quick, log once¶
Say you’re in myapp/models/music.py
import quicklogging
quicklogging.error("Hello world")
Your output will be:
[myapp.models.music - ERROR] Hello world
1.2. Log twice¶
Actually you’re logging more than once in myapp/views/music.py
and want to optimize:
import quicklogging
logger = quicklogging.get_logger()
logger.debug("Howdy?")
This produces:
[myapp.views.music - DEBUG] Howdy?
then,
logger.warning("plop")
produces:
[myapp.views.music - WARNING] plop