Python Glossary Русский

all Python 3loggingfunction

logging.info()

levels

Writes a message at the INFO level. Use it for normal events: startup, successful completion, the status of an operation.

Syntax

logging.info(msg, *args, **kwargs)

The module-level logging.info() writes to the root logger and configures it on the first call — fine in a script, but wrong inside a module or library: create your own logger = logging.getLogger(__name__), otherwise you impose configuration on someone else's application. The line between INFO and DEBUG is about the audience: INFO is read by whoever operates the program (what happened), DEBUG by whoever repairs it (why); a message that only helps you while debugging belongs in debug.

Examples

import logging
logging.basicConfig(level=logging.INFO)
logging.info('Сервер запущен на порту %d', 8080)
logging.info('Загружено %d записей', 1024)

See also

Open in the full glossarydocs.python.orgReport an inaccuracy