1234567891011121314151617181920212223242526 |
- import logging
- import logging.config
- import os
- path = 'log_config.yaml'
- # if os.path.exists(path):
- # with open(path, 'r', encoding='utf-8') as f:
- # config = yaml.load(f)
- # logging.config.dictConfig(config)
- # else:
- logging.basicConfig(
- filename='app-basic.log',
- level=logging.INFO,
- format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
- datefmt='%Y-%m-%d %H:%M:%S'
- )
- def my_log(type,name,msg):
- if type == "info":
- logger = logging.getLogger(name)
- logger.info(msg)
- elif type == "error":
- logger = logging.getLogger(name)
- logger.error(msg)
|