log.py 402 B

1234567891011121314151617
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import logging
  4. # 定义handler的输出格式formatter
  5. formatter = logging.Formatter(
  6. '[%(levelname)1.1s %(asctime)s %(module)s:%(lineno)d] %(message)s'
  7. )
  8. logger = logging.getLogger(__name__)
  9. channel = logging.StreamHandler()
  10. logger.setLevel(logging.DEBUG)
  11. logger.addHandler(channel)
  12. channel.setFormatter(formatter)
  13. channel.setFormatter(formatter)