From 35d570120a814dbc4922a9d48af7bf967406a481 Mon Sep 17 00:00:00 2001 From: Karim shoair Date: Mon, 12 Jan 2026 17:11:52 +0200 Subject: [PATCH] feat(spiders): Add option to logging format and date format --- scrapling/spiders/spider.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scrapling/spiders/spider.py b/scrapling/spiders/spider.py index bc7874c..59ab61c 100644 --- a/scrapling/spiders/spider.py +++ b/scrapling/spiders/spider.py @@ -78,6 +78,8 @@ class Spider(ABC): # Logging settings logging_level: int = logging.DEBUG + logging_format: str = "[%(asctime)s]:({spider_name}) %(levelname)s: %(message)s" + logging_date_format: str = "%Y-%m-%d %H:%M:%S" log_file: Optional[str] = None def __init__(self): @@ -90,7 +92,7 @@ class Spider(ABC): self.logger.propagate = False # Don't propagate to parent 'scrapling' logger formatter = logging.Formatter( - fmt=f"[%(asctime)s]:({self.name}) %(levelname)s: %(message)s", datefmt="%Y-%m-%d %H:%M:%S" + fmt=self.logging_format.format(spider_name=self.name), datefmt=self.logging_date_format ) # Add a log counter handler to track log counts by level