import logging
# The call to `basicConfig()` should come before any calls to `debug()`, `info()`, etc.
# As it’s intended as a one-off simple configuration facility,
# only the first call will actually do anything: subsequent calls are effectively no-ops.
logging.basicConfig(
level=logging.DEBUG,
style='{', # f-string
format='[{levelname}] [{asctime}] {name} {processName}({process}) {message}',
# datefmt='%Y-%m-%d %H:%M:%S'
# logging to file
filename='example.log',
encoding='utf-8'
)
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logger.debug('xxx')
logger.info('xxx')
logger.warning('xxx')
logger.error('xxx')
logger.critical('xxx')