Pamudu13 commited on
Commit
fb6ea6a
·
verified ·
1 Parent(s): a43bacd

Update web_scraper.py

Browse files
Files changed (1) hide show
  1. web_scraper.py +10 -0
web_scraper.py CHANGED
@@ -14,6 +14,16 @@ import logging
14
 
15
  app = Flask(__name__)
16
 
 
 
 
 
 
 
 
 
 
 
17
  logger = logging.getLogger()
18
  queue_handler = QueueHandler()
19
  queue_handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))
 
14
 
15
  app = Flask(__name__)
16
 
17
+ # Create a queue for log messages
18
+ log_queue = queue.Queue()
19
+
20
+ # Custom log handler that puts messages in the queue
21
+ class QueueHandler(logging.Handler):
22
+ def emit(self, record):
23
+ log_entry = self.format(record)
24
+ log_queue.put(log_entry)
25
+
26
+
27
  logger = logging.getLogger()
28
  queue_handler = QueueHandler()
29
  queue_handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))