From 85379fd3ee24523d1d6b031d5ecf8102b30f3c9e Mon Sep 17 00:00:00 2001 From: Delgan Date: Sat, 20 Jul 2024 12:33:48 +0200 Subject: [PATCH] Update "ZMQ" example to stabilize log format (#1070) --- docs/resources/recipes.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/resources/recipes.rst b/docs/resources/recipes.rst index 26547e99..8450bb5f 100644 --- a/docs/resources/recipes.rst +++ b/docs/resources/recipes.rst @@ -323,11 +323,13 @@ Another possibility is to use a third party library like |zmq|_ for example. # client.py import zmq from zmq.log.handlers import PUBHandler + from logging import Formatter from loguru import logger socket = zmq.Context().socket(zmq.PUB) socket.connect("tcp://127.0.0.1:12345") handler = PUBHandler(socket) + handler.setFormatter(Formatter("%(message)s")) logger.add(handler) logger.info("Logging from client")