Python Glossary Русский

all Python 3loggingfunction

logging.critical()

levels

Logs a message at the highest standard level, CRITICAL (50), on the root logger.

Syntax

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

Like the other module-level functions, its first call without configuration runs basicConfig() itself, after which your own basicConfig() call changes nothing. CRITICAL is only a severity: the function does not stop the program, call sys.exit() yourself. In a module prefer logger.critical() on a named logger so the record shows where it came from.

Examples

import logging, sys
logging.basicConfig(stream=sys.stdout, format='%(levelname)s:%(levelno)s %(message)s')
logging.critical('диск заполнен на %d%%', 99)  # → CRITICAL:50 диск заполнен на 99%
print('программа работает дальше')  # → программа работает дальше

See also

Open in the full glossarydocs.python.orgReport an inaccuracy