Loading topic
print gives you no control over what is shown or where it goes. The logging module in the standard library solves this. This chapter shows what 2 min readimport logging before. Here you learn what each level means and how a level decides whether a message is kept or dropped.2 min readbasicConfig. Here you will learn how to create named loggers and why every module should have one.2 min readgetLogger and how the five log levels work. A handler is the object that sends a log record to a destination such as the console, a file, or a network service.2 min readgetLogger and attach handlers to them. It explains how Python connects loggers to each other and how a record travels between them.2 min readtry/except, can create a named logger with logging.getLogger(__name__), and have used basicConfig. It shows how to record an error together with its traceback, so a log entry tells you where the failure happened and not only that it happened.2 min readLogRecord moves from a logger to its handlers. You should also be comfortable writing a small class that inherits from another.2 min readlogging.config.dictConfig builds all of those objects from one dictionary. The configuration then lives in one place, and you can load it from JSON or YAML.2 min readunittest test classes. Log messages are part of a program's observable behavior. Operators rely on them, so a test can check that a warning was emitted when something went wrong. The standard library provides `TestCase.asser2 min readdictConfig from earlier chapters. It collects the habits that keep logging correct and cheap, and the mistakes that cause missing or duplicated output.2 min read