Oh God, please tell me you have the logs…
You never know how much logging is important until you face a mysterious problem you can't quite figure out. Understanding why something wrong happened is the first, and probably main, reason why people add logging to their projects. But, hey, what's logging?
Logging is the act of storing records about events for further later analysis. An important concept about logging is related to the logging level, which allows you to categorize the information type and relevance.
The Python standard library comes bundled with a logging library that is actually pretty powerful and allows you, through handlers and messages, to log to streams, files, e-mail, or any other solution you believe will fit. Let's try a few useful logging examples, shall we?
# coding:utf-8 from flask import Flask import logging from logging.handlers import RotatingFileHandler app = Flask(__name__) # default flask logging handler pushes messages into the console # works DEBUG mode only...