Method Name
critical
Method Signature
critical(logMessage, *args, **kwargs)
Method Overview
critical() method of logger class writes a log message of severity logger.CRITICAL to the stderr. stderr is typically mapped to the console.
The *args, **kwargs help to enrich the log message which more information like date and time, ip address of the machine, line number of the module, exception information and stack information. These optional arguments to the critical method are explained as part of logging a debug message in a Python Program.
Developers log messages of logger.CRITICAL to record events that are catastrophic to the further execution of the program itself.
Examples include Unable to write a disk, Failure to allocate a memory buffer as physical memory consumption has reached the maximum, a stack overflow and so on.
Example
# import the logging module
import logging
# Set a log prefix for critical messages
formatString = '%(asctime)s %(filename)s %(processName)s => %(message)s'
logging.basicConfig(format=formatString)
# Get a logger with the name of current module
logr = logging.getLogger(__name__)
# Log a message with severity logging.CRITICAL
logr.critical("***Pseudo***This is a Critical Message")Output
2017-03-25 13:43:16,974 logr5.py MainProcess => ***Pseudo***This is a Critical Message