Closed orazdow closed 1 month ago
Try to do this
cl = Client()
cl.logger.setLevel(logging.DEBUG)
Is the best way to get the error string from the logger to add a handler I guess?
for such a task you need something like this
import logging
from instagrapi import Client
# Custom handler to intercept log messages
class ErrorInterceptHandler(logging.Handler):
def emit(self, record):
if record.levelno >= logging.ERROR:
# Intercept the error log here (do whatever you need with it)
print(f"Intercepted error: {record.getMessage()}")
# Configure logging
cl = Client()
cl.logger.setLevel(logging.DEBUG)
# Add our custom handler
error_handler = ErrorInterceptHandler()
cl.logger.addHandler(error_handler)
Ok thanks
Is it possible intercept error response messages using the cl object's logger?