Skip to content

Commit 15aacb6

Browse files
committed
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.
1 parent 0058274 commit 15aacb6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

README.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,12 @@ You can inject your own custom proc to handle buffer overflow in the event of co
167167
import msgpack
168168
from io import BytesIO
169169
170-
def handler(pendings):
170+
def overflow_handler(pendings):
171171
unpacker = msgpack.Unpacker(BytesIO(pendings))
172172
for unpacked in unpacker:
173173
print(unpacked)
174174
175-
logger = sender.FluentSender('app', host='host', port=24224, buffer_overflow_handler=handler)
175+
logger = sender.FluentSender('app', host='host', port=24224, buffer_overflow_handler=overflow_handler)
176176
177177
You should handle any exception in handler. fluent-logger ignores exceptions from ``buffer_overflow_handler``.
178178

@@ -198,7 +198,7 @@ module.
198198
199199
logging.basicConfig(level=logging.INFO)
200200
l = logging.getLogger('fluent.test')
201-
h = handler.FluentHandler('app.follow', host='host', port=24224, buffer_overflow_handler=handler)
201+
h = handler.FluentHandler('app.follow', host='host', port=24224, buffer_overflow_handler=overflow_handler)
202202
formatter = handler.FluentRecordFormatter(custom_format)
203203
h.setFormatter(formatter)
204204
l.addHandler(h)
@@ -228,7 +228,7 @@ You can inject your own custom proc to handle buffer overflow in the event of co
228228
import msgpack
229229
from io import BytesIO
230230
231-
def handler(pendings):
231+
def overflow_handler(pendings):
232232
unpacker = msgpack.Unpacker(BytesIO(pendings))
233233
for unpacked in unpacker:
234234
print(unpacked)
@@ -264,7 +264,7 @@ A sample configuration ``logging.yaml`` would be:
264264
host: localhost
265265
port: 24224
266266
tag: test.logging
267-
buffer_overflow_handler: handler
267+
buffer_overflow_handler: overflow_handler
268268
formatter: fluent_fmt
269269
level: DEBUG
270270
none:

0 commit comments

Comments
 (0)