logger.py 473 B

1234567891011121314
  1. import os
  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(__file__), F'logs_{now.year}{now.month}{now.day}.log')
  7. print(file_log)
  8. logging.basicConfig(filename=file_log,
  9. encoding='utf-8',
  10. level=logging.DEBUG,
  11. format='%(asctime)s %(name)s %(levelname)s %(message)s')
  12. logger = logging.getLogger(__name__)