A stream handler sends log records to an interactive console, giving developers immediate feedback while an application runs. Create one with logging.StreamHandler() and attach it to a logger with addHandler(). A logger can use a stream handler alongside one or more file handlers, allowing real-time viewing and longer-term storage of the same event. section 12.1.3 section 12.1.4
Show a warning in the console
stream_handler = logging.StreamHandler() logger.addHandler(stream_handler) logger.warning("Just a random warning event.") # output: Just a random warning event.
Configure the handler with a logging level and Formatter when readable records matter. Include the event time, severity, module name, and message so that errors are easier to locate and correlate with outside events. The Formatter uses %-style fields rather than f-strings. section 12.2.3
