1

i'm trying to setup a "logentries" account to log my python development events. But I get the following error even with the most simple test available in the documentation. Any thoughts?

Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] on wi
n32
Type "help", "copyright", "credits" or "license" for more information.
>>> from logentries import LogentriesHandler
>>> import logging
>>> log = logging.getLogger('logentries')
>>> log.setLevel(logging.INFO)
>>> log.addHandler(LogentriesHandler('xxxx-xxxx-xxxx-xxxx-xxxx'))
>>> log.info('teste')
LE: Starting Logentries Asynchronous Socket Appender
>>> Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Python27\lib\threading.py", line 810, in __bootstrap_inner
    self.run()
  File "C:\Python27\lib\site-packages\logentries\utils.py", line 96, in run
    multiline = le_helpers.create_unicode(data).replace(
  File "C:\Python27\lib\site-packages\logentries\helpers.py", line 31, in create
_unicode
    return unicode(ch, 'utf-8')
UnicodeDecodeError: 'utf8' codec can't decode byte 0xe1 in position 59: invalid
continuation byte
1
  • It seems that ch doesn't contain valid utf-8 byte string. What value is in ch at the moment of exception? At least how ch gets it value? // You could try to use third parameter of the function, i.e. unicode(ch, 'utf-8', 'replace'), but this will replace all invalid bytes with "?". Default is 'strict' that is why it raises an exception. Commented Dec 7, 2015 at 18:21

1 Answer 1

1

Thanks to Nikita's comment I could find the problem.

Helpers.py lib from logentries are not prepared for latin languages OS, whose timestamp label have special letters as "á".

Replacing

unicode(ch,'utf8')

with

unicode(ch,'utf8','replace')

did the trick.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.