logger.py 461 B

12345678910111213
  1. import os, sys
  2. from datetime import datetime
  3. import logging
  4. def create_logger():
  5. now = datetime.now()
  6. file_log = os.path.join(os.path.dirname(sys.argv[0]), F'logs_{now.year}{now.month}{now.day}.log')
  7. logging.basicConfig(filename=file_log,
  8. encoding='utf-8',
  9. level=logging.DEBUG,
  10. format='%(asctime)s %(name)s %(levelname)s %(message)s')
  11. logger = logging.getLogger(__name__)