Spaces:
Build error
Build error
import logging | |
import structlog | |
import sys | |
from pythonjsonlogger import jsonlogger | |
def init_logger(): | |
structlog.configure( | |
processors=[ | |
structlog.stdlib.filter_by_level, | |
structlog.stdlib.add_logger_name, | |
structlog.stdlib.add_log_level, | |
structlog.stdlib.PositionalArgumentsFormatter(), | |
structlog.processors.StackInfoRenderer(), | |
structlog.processors.format_exc_info, | |
structlog.processors.UnicodeDecoder(), | |
structlog.stdlib.render_to_log_kwargs, | |
], | |
logger_factory=structlog.stdlib.LoggerFactory(), | |
wrapper_class=structlog.stdlib.BoundLogger, | |
cache_logger_on_first_use=True, | |
) | |
handler = logging.StreamHandler(sys.stdout) | |
handler.setFormatter(jsonlogger.JsonFormatter()) | |
root_logger = logging.getLogger() | |
root_logger.addHandler(handler) | |