Skip to content

🕷️ The BEST Web Scraping framework that handles everything from a single request to a full-scale crawl! Don't be shy, join here: https://discord.gg/EMgGbDceNQ and follow here for daily tips and tricks: https://x.com/Scrapling_dev

feat(spiders): Add option to logging format and date format

Karim shoair35d570120a81
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