22 logging module
'''
1. Using logging module we can log based on severity level.
2. By default, there are 5 standard levels indicating the severity of events.
3. Log levels are ==> INFO, DEBUG, WARNING, ERROR, CRITICAL
4. The default level is WARNING
'''
import logging
logging.info(" TEST 1 ")
logging.debug(" TEST 2 ")
logging.warning(" TEST 3 ")
logging.error(" TEST 4 ")
logging.critical(" TEST 5 ")
'''
datefmt='%m/%d/%Y %I:%M:%S %p'
'''
import logging
logging.basicConfig(level=logging.DEBUG,
format='%(levelname)s %(asctime)s %(message)s ',
datefmt='%m/%d/%Y %H/%M/%S %p',
filename='debug.log',
filemode='w'
)
logging.info(' :: TEST 1 ')
logging.debug(' :: TEST 2 ')
logging.warning(' :: TEST 3 ')
logging.error(' :: TEST 4 ')
logging.critical(" :: TEST 5 ")
Comments
Post a Comment