log.py 352 B

1234567891011121314
  1. from pathlib import Path
  2. from loguru import logger
  3. _absolute = Path(__file__).absolute().parent.parent
  4. _log_path = (_absolute / 'logs/crawl_{time:YYYYMMDD}.log').resolve()
  5. logger.add(
  6. _log_path,
  7. format='{time:YYYY-MM-DD HH:mm:ss} - {level} - {message}',
  8. level='INFO',
  9. rotation='00:00',
  10. retention='1 week',
  11. encoding='utf-8',
  12. )