Skip to content

Commit 35d5701

Browse files
committed
feat(spiders): Add option to logging format and date format
1 parent 3466bca commit 35d5701

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

scrapling/spiders/spider.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ class Spider(ABC):
7878

7979
# Logging settings
8080
logging_level: int = logging.DEBUG
81+
logging_format: str = "[%(asctime)s]:({spider_name}) %(levelname)s: %(message)s"
82+
logging_date_format: str = "%Y-%m-%d %H:%M:%S"
8183
log_file: Optional[str] = None
8284

8385
def __init__(self):
@@ -90,7 +92,7 @@ def __init__(self):
9092
self.logger.propagate = False # Don't propagate to parent 'scrapling' logger
9193

9294
formatter = logging.Formatter(
93-
fmt=f"[%(asctime)s]:({self.name}) %(levelname)s: %(message)s", datefmt="%Y-%m-%d %H:%M:%S"
95+
fmt=self.logging_format.format(spider_name=self.name), datefmt=self.logging_date_format
9496
)
9597

9698
# Add a log counter handler to track log counts by level

0 commit comments

Comments
 (0)