Hi with the python standard logging library, we are able to setup a queue and a listener so that logs are non blocking. Are we able to setup something similar with structlog?
Example from the standard logging library docs:
que = queue.Queue(-1) # no limit on size
queue_handler = QueueHandler(que)
handler = logging.StreamHandler()
listener = QueueListener(que, handler)
root = logging.getLogger()
root.addHandler(queue_handler)
formatter = logging.Formatter('%(threadName)s: %(message)s')
handler.setFormatter(formatter)
listener.start()
# The log output will display the thread which generated
# the event (the main thread) rather than the internal
# thread which monitors the internal queue. This is what
# you want to happen.
root.warning('Look out!')
listener.stop()
Python standard logging library reference:
https://docs.python.org/3/howto/logging-cookbook.html#dealing-with-handlers-that-block
Hi with the python standard logging library, we are able to setup a queue and a listener so that logs are non blocking. Are we able to setup something similar with structlog?
Example from the standard logging library docs:
Python standard logging library reference:
https://docs.python.org/3/howto/logging-cookbook.html#dealing-with-handlers-that-block