Skip to content

Instantly share code, notes, and snippets.

@akhoronko
Created May 8, 2018 14:32
Show Gist options
  • Save akhoronko/98665bf5229daf92f621d677239fbb83 to your computer and use it in GitHub Desktop.
Save akhoronko/98665bf5229daf92f621d677239fbb83 to your computer and use it in GitHub Desktop.
logging error with more than 255 chinks
import logging
from graypy import GELFHandler
chunk_size = 1
handler = GELFHandler('127.0.0.1', compress=False, chunk_size=chunk_size)
logger = logging.getLogger()
logger.addHandler(handler)
# in chunked GELF sequence count is 1 byte, so there can't be more than 255 chunks
message = ' ' * chunk_size * 256
logger.info(message)
# Traceback (most recent call last):
# File "/usr/lib/python2.7/logging/handlers.py", line 581, in emit
# self.send(s)
# File "/home/andrey/platform/backend/env/local/lib/python2.7/site-packages/graypy/handler.py", line 60, in send
# for chunk in ChunkedGELF(s, self.chunk_size):
# File "/home/andrey/platform/backend/env/local/lib/python2.7/site-packages/graypy/handler.py", line 76, in __init__
# self.pieces = struct.pack('B', int(math.ceil(len(message) * 1.0/size)))
# error: ubyte format requires 0 <= number <= 255
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment