logentriescommunity / le_python Goto Github PK
View Code? Open in Web Editor NEWLogentries support for Python
License: MIT License
Logentries support for Python
License: MIT License
pip install logentries
breaks on Windows. v0.15 installed fine for me, but installing v0.16 results in:
(.venv) C:\Work\external\le_python>python setup.py install
running install
running bdist_egg
error: error in 'egg_base' option: '/tmp' does not exist or is not a directory
Hi, i'm trying to use python logentries behind a firewall, but reading https://github.com/logentries/le_python/blob/master/logentries/utils.py i see it tries to use port 10000 and documentation says it should use ports 80 and 443.
It will be a good idea to add this information somewhere in the README
I get UnicodeError exception at some reports. An example exception:
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1423, in log_
exception
), exc_info=exc_info)
File "/usr/lib/python2.7/logging/__init__.py", line 1174, in error
self._log(ERROR, msg, args, **kwargs)
File "/usr/lib/python2.7/logging/__init__.py", line 1267, in _log
self.handle(record)
File "/usr/lib/python2.7/logging/__init__.py", line 1277, in handle
self.callHandlers(record)
File "/usr/lib/python2.7/logging/__init__.py", line 1317, in callHandlers
hdlr.handle(record)
File "/usr/lib/python2.7/logging/__init__.py", line 748, in handle
self.emit(record)
File "/usr/local/lib/python2.7/dist-packages/logentries/utils.py", line 124, i
n emit
msg = self.format(record).rstrip('\n')
File "/usr/lib/python2.7/logging/__init__.py", line 723, in format
return fmt.format(record)
File "/usr/lib/python2.7/logging/__init__.py", line 467, in format
s = self._fmt % record.__dict__
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)
Hi,
I'm using Mac OS X 10.9.4 and Python 2.7.5
I have created my account on Logentries, and using the code generated by the app (with token), running the logging.py on the Terminal.
The installation:
$ sudo pip install logentries
Downloading/unpacking logentries
Downloading Logentries-0.2.1.tar.gz
Running setup.py egg_info for package logentries
Installing collected packages: logentries
Running setup.py install for logentries
Successfully installed logentries
Cleaning up...
$ sudo pip freeze | grep entries
LogentriesLogger==0.2.1
The snippet that I use:
from logentries import LogentriesHandler
import logging
import time
log = logging.getLogger('logentries')
log.setLevel(logging.INFO)
test = LogentriesHandler('--- MY TOKEN ---')
log.addHandler(test)
log.warn("Warning message")
log.info("Info message")
time.sleep(10)
When run the snippet show this stack trace:
$ python logging.py
Traceback (most recent call last):
File "logging.py", line 3, in
from logentries import LogentriesHandler
File "/Library/Python/2.7/site-packages/logentries/init.py", line 1, in
from .utils import LogentriesHandler
File "/Library/Python/2.7/site-packages/logentries/utils.py", line 9, in
import logging
File "/Users/myuser/Desktop/logging.py", line 3, in
from logentries import LogentriesHandler
I would like to use a wrapper around a Python WSGI app. Check out how Sentry wraps around Python WSGI apps:
https://docs.getsentry.com/hosted/clients/python/integrations/wsgi/
I created 2 handlers and two loggers using the logentries on my Django project.
When I start my celery worker, I geting RuntimeError "threads can only be started once".
I'm using:
django 1.5
celery 3.1.7
Track:
File "/home/user/.virtualenvs/celery3.1/local/lib/python2.7/site-packages/celery/worker/__init__.py", line 206, in start
self.blueprint.start(self)
File "/home/user/.virtualenvs/celery3.1/local/lib/python2.7/site-packages/celery/bootsteps.py", line 123, in start
step.start(parent)
File "/home/user/.virtualenvs/celery3.1/local/lib/python2.7/site-packages/celery/bootsteps.py", line 373, in start
return self.obj.start()
File "/home/user/.virtualenvs/celery3.1/local/lib/python2.7/site-packages/celery/worker/consumer.py", line 270, in start
blueprint.start(self)
File "/home/user/.virtualenvs/celery3.1/local/lib/python2.7/site-packages/celery/bootsteps.py", line 123, in start
step.start(parent)
File "/home/user/.virtualenvs/celery3.1/local/lib/python2.7/site-packages/celery/worker/consumer.py", line 469, in start
info('Connected to %s', c.connection.as_uri())
File "/usr/lib/python2.7/logging/__init__.py", line 1140, in info
self._log(INFO, msg, args, **kwargs)
File "/usr/lib/python2.7/logging/__init__.py", line 1258, in _log
self.handle(record)
File "/usr/lib/python2.7/logging/__init__.py", line 1268, in handle
self.callHandlers(record)
File "/usr/lib/python2.7/logging/__init__.py", line 1308, in callHandlers
hdlr.handle(record)
File "/usr/lib/python2.7/logging/__init__.py", line 748, in handle
self.emit(record)
File "/home/user/Dropbox/workspace/paas/appfog/soar-site/logentries/utils.py", line 132, in emit
self._thread.start()
File "/usr/lib/python2.7/threading.py", line 488, in start
raise RuntimeError("threads can only be started once")
RuntimeError: threads can only be started once
Your documentation suggests to install version 0.2
but I kept getting this error below. I've already installed 0.2.1
, but just wanted you to be aware. Thanks! Keep up the great work!
pip install logentries==0.2
Downloading/unpacking logentries==0.2
Could not find a version that satisfies the requirement logentries==0.2 (from versions: 0.2.1)
Cleaning up...
No distributions matching the version for logentries==0.2
Downloading/unpacking logentries==0.2
Getting page https://pypi.python.org/simple/logentries/
URLs to search for versions for logentries==0.2:
* https://pypi.python.org/simple/logentries/0.2
* https://pypi.python.org/simple/logentries/
Getting page https://pypi.python.org/simple/logentries/0.2
Could not fetch URL https://pypi.python.org/simple/logentries/0.2: HTTP Error 404: Not Found
Will skip URL https://pypi.python.org/simple/logentries/0.2 when looking for download links for logentries==0.2
Analyzing links from page https://pypi.python.org/simple/logentries/
Found link https://pypi.python.org/packages/source/L/Logentries/Logentries-0.2.1.tar.gz#md5=82a91dbd932a66d9c006659bf520bcd5 (from https://pypi.python.org/simple/logentries/), version: 0.2.1
Ignoring link https://pypi.python.org/packages/source/L/Logentries/Logentries-0.2.1.tar.gz#md5=82a91dbd932a66d9c006659bf520bcd5 (from https://pypi.python.org/simple/logentries/), version 0.2.1 doesn't match ==0.2
Could not find a version that satisfies the requirement logentries==0.2 (from versions: 0.2.1)
Also, the 0.5 package on pypi has broken our build, please fix ASAP.
On a fresh clone I get:
In [1]: import logentries
File "logentries/utils.py", line 187
finally:
^
SyntaxError: invalid syntax
It looks like this library supports python 3, but I'm not 100% sure. If so, could you make it so that this tool doesn't report the library as blocking:
https://caniusepython3.com/project/Logentries
I think what you need to do is add classifiers to setup.py like this:
classifiers=[
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
]
We found this exception during testing:
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/local/lib/python2.7/dist-packages/logentries/utils.py", line 96, in run
multiline = le_helpers.create_unicode(data).replace(
File "/usr/local/lib/python2.7/dist-packages/logentries/helpers.py", line 31, in create_unicode
return unicode(ch, 'utf-8')
UnicodeDecodeError: 'utf8' codec can't decode byte 0xf5 in position 716: invalid start byte
> python --version
Python 2.7.6
Since the worker thread dies, the whole application will suddenly stop working because of #48
Please copy in full the usage example from the Logentries website:
https://logentries.com/doc/python/
and also put the notice that "this is asynchronous and that you cannot exit just after sending a log message". This thing got me.
thanks
setup.py point to LICENSE.txt file which is absent.
Please add information about license on which this code can be used.
logentries.utils.TLSSocketAppender
use certifi.where()
to locate root certifications, but certifi.where()
doesn't know frozen environment and provided wrong certification path when running in frozen executables. This leads to continuously output of error LE: Unable to connect to Logentries
.
Maybe le_python could provide a environment variable to override root certification path. At least that would allow applications to manually include necessary certifications and make them available to le_python.
The logger.warning(e)
happens in a loop and this can try to send a lot of logs.
Traceback:
File "[...]/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 114, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "[...]/local/lib/python2.7/site-packages/django/views/generic/base.py", line 69, in view
return self.dispatch(request, *args, **kwargs)
File "[...]/local/lib/python2.7/site-packages/newrelic-2.40.0.34/newrelic/hooks/component_djangorestframework.py", line 8, in _nr_wrapper_APIView_dispatch_
return wrapped(*args, **kwargs)
File "[...]/local/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 57, in wrapped_view
return view_func(*args, **kwargs)
File "[...]/local/lib/python2.7/site-packages/rest_framework/views.py", line 400, in dispatch
response = self.handle_exception(exc)
File "[...]/local/lib/python2.7/site-packages/rest_framework/views.py", line 397, in dispatch
response = handler(request, *args, **kwargs)
File "./api/views/filemanager.py", line 49, in get
return Response(serializer.list_files_in_folder(path, images_only), 200)
File "./api/serializers/filemanager.py", line 156, in list_files_in_folder
logger.warning(e)
File "/usr/lib/python2.7/logging/__init__.py", line 1152, in warning
self._log(WARNING, msg, args, **kwargs)
File "/usr/lib/python2.7/logging/__init__.py", line 1258, in _log
self.handle(record)
File "/usr/lib/python2.7/logging/__init__.py", line 1268, in handle
self.callHandlers(record)
File "/usr/lib/python2.7/logging/__init__.py", line 1308, in callHandlers
hdlr.handle(record)
File "/usr/lib/python2.7/logging/__init__.py", line 748, in handle
self.emit(record)
File "[...]/local/lib/python2.7/site-packages/logentries/utils.py", line 124, in emit
self._thread.start()
File "/usr/lib/python2.7/threading.py", line 494, in start
_start_new_thread(self.__bootstrap, ())
error: can't start new thread
Please ๐ ๐
https://pypi.python.org/pypi/Logentries/0.2 is broken
It hosts a LogentriesLogger==0.2.1 package instead of the expected logentries package
Which is available at the apparantly canonical https://pypi.python.org/pypi/LogentriesLogger/ location.
I'm getting following error while installing linux agent
***** Step 2 of 3 - Login *****
Traceback (most recent call last):
File "/usr/bin/le", line 8, in ?
sys.exit(
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 236, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 2097, in load_entry_point
return ep.load()
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 1830, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/share/logentries/logentries/le.py", line 2375
return resp['host'] if resp['response'] == 'ok' else None
^
SyntaxError: invalid syntax
We have a web app using django and gunicorn, I don't appreciate how gunicorn handles its workers but after the recent changes we're getting:
2013-10-08 12:28:31 [ERROR] gunicorn.error: Error handling request
Traceback (most recent call last):
File "/home/ubuntu/venv/local/lib/python2.7/site-packages/gunicorn/workers/async.py", line 55, in handle
self.handle_error(req, client, addr, e)
File "/home/ubuntu/venv/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 177, in handle_error
self.log.exception("Error handling request")
File "/home/ubuntu/venv/local/lib/python2.7/site-packages/gunicorn/glogging.py", line 219, in exception
self.error_log.exception(msg, *args)
File "/usr/lib/python2.7/logging/__init__.py", line 1172, in exception
self.error(msg, exc_info=1, *args)
File "/usr/lib/python2.7/logging/__init__.py", line 1166, in error
self._log(ERROR, msg, args, **kwargs)
File "/usr/lib/python2.7/logging/__init__.py", line 1258, in _log
self.handle(record)
File "/usr/lib/python2.7/logging/__init__.py", line 1268, in handle
self.callHandlers(record)
File "/usr/lib/python2.7/logging/__init__.py", line 1308, in callHandlers
hdlr.handle(record)
File "/usr/lib/python2.7/logging/__init__.py", line 748, in handle
self.emit(record)
File "/home/ubuntu/venv/src/logentries/logentries/utils.py", line 122, in emit
self._thread.start()
File "/usr/lib/python2.7/threading.py", line 488, in start
raise RuntimeError("threads can only be started once")
RuntimeError: threads can only be started once
If there's any further information I can provide that might help please let me know, also apologies if this is not an issue for le_python, however when we moved to commit 1726b2271b0fa6d9da4332e165f4ae394e4ffd47
it seems to have resolved the problem. We're using gunicorn 18.0, python 2.7, ubuntu, and we're monkey patching gunicorn. from gevent import monkey; monkey.patch_all(subprocess=False)
Hello,
The lib installed by pip (1.7) is broken apparently, it fails with an error message saying inconsistent use of tabs and whitespace
inside metrics.py file
However the git version does not seem to have this issue.
I had to do some very dirty workarounds to get it working in an automated way...
Could you please check what the problem is?
Regards.
It's currently confusing having two differently named packages up on pypi, it would be best to remove https://pypi.python.org/pypi/LogentriesLogger/. However would this case massive issues for people currently using the appender?
Hey,
I configured the logging as described on the website however its not working properly.
https://logentries.com/doc/django/ but I can't see any request logs incoming. If not using Django, is there any way I could easily achieve this directly using uwsgi?
If the queue is full, the Full exception https://docs.python.org/2/library/queue.html#Queue.Full isn't handled but propagated to the caller.
https://github.com/logentries/le_python/blob/master/logentries/utils.py#L192
The logger should drop the message instead. Better than crashing the the program.
Jan
In setup.py
install_requires=[
"certifi",
],
This causes errors when using the requests library to access https://storage.googleapis.com
requests.exceptions.SSLError: [Errno 1] _ssl.c:510: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Even though not directly your bug, having this as a requirement in your setup messes up the environment so I think you should consider solving this as well.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.