Skip to content

Ensure junebug logging service doesn't fail for invalid characters #123

@rudigiesler

Description

@rudigiesler

See this exception:

2017-04-22T17:07:34.197830599Z /usr/local/lib/python2.7/site-packages/twisted/python/log.py:136:err
2017-04-22T17:07:34.197850244Z /usr/local/lib/python2.7/site-packages/twisted/python/threadable.py:53:sync
2017-04-22T17:07:34.197863311Z /usr/local/lib/python2.7/site-packages/twisted/python/log.py:286:msg
2017-04-22T17:07:34.197875809Z /usr/local/lib/python2.7/site-packages/twisted/logger/_legacy.py:154:publishToNewObserver
2017-04-22T17:07:34.197888171Z --- <exception caught here> ---
2017-04-22T17:07:34.197900604Z /usr/local/lib/python2.7/site-packages/twisted/logger/_observer.py:131:__call__
2017-04-22T17:07:34.197912892Z /usr/local/lib/python2.7/site-packages/twisted/logger/_legacy.py:93:__call__
2017-04-22T17:07:34.197925351Z /usr/local/lib/python2.7/site-packages/junebug/logging_service.py:84:__call__
2017-04-22T17:07:34.197937620Z /usr/local/lib/python2.7/site-packages/twisted/python/log.py:86:callWithContext
2017-04-22T17:07:34.197949877Z /usr/local/lib/python2.7/site-packages/twisted/python/context.py:118:callWithContext
2017-04-22T17:07:34.197962300Z /usr/local/lib/python2.7/site-packages/twisted/python/context.py:81:callWithContext
2017-04-22T17:07:34.197974539Z /usr/local/lib/python2.7/site-packages/junebug/logging_service.py:77:_log_to_file
2017-04-22T17:07:34.197987120Z /usr/local/lib/python2.7/json/__init__.py:244:dumps
2017-04-22T17:07:34.197999058Z /usr/local/lib/python2.7/json/encoder.py:207:encode
2017-04-22T17:07:34.198011037Z /usr/local/lib/python2.7/json/encoder.py:270:iterencode
2017-04-22T17:07:34.198023085Z ]
2017-04-22T17:07:34.198035010Z Traceback (most recent call last):
2017-04-22T17:07:34.198047055Z   File "/usr/local/lib/python2.7/site-packages/twisted/logger/_observer.py", line 131, in __call__
2017-04-22T17:07:34.198059577Z     observer(event)
2017-04-22T17:07:34.198071368Z   File "/usr/local/lib/python2.7/site-packages/twisted/logger/_legacy.py", line 93, in __call__
2017-04-22T17:07:34.198083780Z     self.legacyObserver(event)
2017-04-22T17:07:34.198107529Z   File "/usr/local/lib/python2.7/site-packages/junebug/logging_service.py", line 84, in __call__
2017-04-22T17:07:34.198121308Z     log.callWithContext(self.log_context, self._log_to_file, event)
2017-04-22T17:07:34.198133328Z   File "/usr/local/lib/python2.7/site-packages/twisted/python/log.py", line 86, in callWithContext
2017-04-22T17:07:34.198145762Z     return context.call({ILogContext: newCtx}, func, *args, **kw)
2017-04-22T17:07:34.198157786Z   File "/usr/local/lib/python2.7/site-packages/twisted/python/context.py", line 118, in callWithContext
2017-04-22T17:07:34.198170446Z     return self.currentContext().callWithContext(ctx, func, *args, **kw)
2017-04-22T17:07:34.198182473Z   File "/usr/local/lib/python2.7/site-packages/twisted/python/context.py", line 81, in callWithContext
2017-04-22T17:07:34.198194759Z     return func(*args,**kw)
2017-04-22T17:07:34.198206461Z   File "/usr/local/lib/python2.7/site-packages/junebug/logging_service.py", line 77, in _log_to_file
2017-04-22T17:07:34.198218759Z     self.logfile.write(json.dumps(data) + '\n')
2017-04-22T17:07:34.198230977Z   File "/usr/local/lib/python2.7/json/__init__.py", line 244, in dumps
2017-04-22T17:07:34.198243080Z     return _default_encoder.encode(obj)
2017-04-22T17:07:34.198254992Z   File "/usr/local/lib/python2.7/json/encoder.py", line 207, in encode
2017-04-22T17:07:34.198267007Z     chunks = self.iterencode(o, _one_shot=True)
2017-04-22T17:07:34.198278859Z   File "/usr/local/lib/python2.7/json/encoder.py", line 270, in iterencode
2017-04-22T17:07:34.198290939Z     return _iterencode(o, 0)
2017-04-22T17:07:34.198304390Z UnicodeDecodeError: 'utf8' codec can't decode byte 0xf1 in position 146: invalid continuation byte```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions