Loading topic
try/except. It also assumes you have run a script from a terminal. The previous chapter explained why logging beats print. This chapter covers the feature that makes it work: severity levels. You will learn what the five5 min readlogging.basicConfig(), the one-call setup for scripts and small programs. It assumes you can read basic Python, run scripts from a terminal, and know that logging has levels such as DEBUG and INFO. Loggers, handlers, and formatters get their own chapters. Here you only need to 4 min readbasicConfig once (covered in the previous chapter). It explains how to create loggers, what names to give them, and the mistakes that come from skipping this step.5 min readlogging.getLogger, you know the five log levels, and you are comfortable subclassing a class in Python. Formatters and the logger hierarchy get their own chapters, so they appear h5 min readlogging.Formatter turns a LogRecord into the text a handler writes, and the errors that come up when you customize that step.4 min readlogging.getLogger, know the five standard levels, and have attached a handler to a logger. It covers how Python connects loggers into a tree and how a record travels through that tree. Most surprises in logging (duplicate lines, missing messages, 5 min readtry/except, you know the log levels, and you know how a logger passes records to handlers. It covers how to log an exception without losing its traceback, the options that control this, and the mistakes that make logs noisy or misleading.5 min readFileHandler is new to you, review the earlier chapter on handlers first.5 min readjq command has to guess where the timestamp ends and the message begins. Structured logging writes each record as one JSON object per line, so every field has a name and a type.4 min readunittest.TestCase. It shows how to check that your code logs what it should, without reading log files or patching print.4 min readthreading and queue at a basic level.5 min readdictConfig from the previous chapters, and that you can read a short Python script. Most logging bugs come from a few causes: configuring in the wrong pl5 min read