mlogging.py 706 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. '''
  4. 注意文件名直接写 logging.py 会出错!所以说python文件命名都有规范!
  5. @Auther :liuyuqi.gov@msn.cn
  6. @Time :2018/7/8 13:09
  7. @File :mlogging.py
  8. '''
  9. import logging
  10. class Log():
  11. def __init__(self):
  12. logging.basicConfig(level=logging.DEBUG,
  13. format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
  14. datefmt='%a, %d %b %Y %H:%M:%S',
  15. filename='myapp.log',
  16. filemode='w')
  17. def debug(msg):
  18. logging.debug(msg)
  19. def info(msg):
  20. logging.info(msg)
  21. def warning(msg):
  22. logging.warning(msg)