From 15aacb66715c48c875b11f52e437a9453f344e1d Mon Sep 17 00:00:00 2001 From: Yoichi Nakayama Date: Tue, 9 May 2017 23:59:41 +0900 Subject: [PATCH] avoid invalid use of buffer_overflow_handler in the example FluentHandler does receive buffer_overflow_handler, and its value should be a callable. Since logging.Handler example already has handler module in the scope, it will construct FluentHandler with meaningless buffer overflow handler (TypeError is raised and ignored). This change renames the example handler and cause NameError if there is no handler definition. --- README.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 97bbdb1..8d34d5d 100644 --- a/README.rst +++ b/README.rst @@ -167,12 +167,12 @@ You can inject your own custom proc to handle buffer overflow in the event of co import msgpack from io import BytesIO - def handler(pendings): + def overflow_handler(pendings): unpacker = msgpack.Unpacker(BytesIO(pendings)) for unpacked in unpacker: print(unpacked) - logger = sender.FluentSender('app', host='host', port=24224, buffer_overflow_handler=handler) + logger = sender.FluentSender('app', host='host', port=24224, buffer_overflow_handler=overflow_handler) You should handle any exception in handler. fluent-logger ignores exceptions from ``buffer_overflow_handler``. @@ -198,7 +198,7 @@ module. logging.basicConfig(level=logging.INFO) l = logging.getLogger('fluent.test') - h = handler.FluentHandler('app.follow', host='host', port=24224, buffer_overflow_handler=handler) + h = handler.FluentHandler('app.follow', host='host', port=24224, buffer_overflow_handler=overflow_handler) formatter = handler.FluentRecordFormatter(custom_format) h.setFormatter(formatter) l.addHandler(h) @@ -228,7 +228,7 @@ You can inject your own custom proc to handle buffer overflow in the event of co import msgpack from io import BytesIO - def handler(pendings): + def overflow_handler(pendings): unpacker = msgpack.Unpacker(BytesIO(pendings)) for unpacked in unpacker: print(unpacked) @@ -264,7 +264,7 @@ A sample configuration ``logging.yaml`` would be: host: localhost port: 24224 tag: test.logging - buffer_overflow_handler: handler + buffer_overflow_handler: overflow_handler formatter: fluent_fmt level: DEBUG none: