Browse Source

日志库

dongzhaorui 3 years ago
parent
commit
d623a74c0c
1 changed files with 14 additions and 0 deletions
  1. 14 0
      find_source/common/log.py

+ 14 - 0
find_source/common/log.py

@@ -0,0 +1,14 @@
+from pathlib import Path
+
+from loguru import logger
+
+_absolute = Path(__file__).absolute().parent.parent
+_log_path = (_absolute / 'logs/crawl-{time:YYYY-MM-DD}.log').resolve()
+logger.add(
+    _log_path,
+    format='{time:YYYY-MM-DD HH:mm:ss} - {level} - {message}',
+    level='INFO',
+    rotation='00:00',
+    retention='1 week',
+    encoding='utf-8',
+)