Update web_scraper.py
Browse files- 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'))
|