Sentry Logs allows you to send logs to Sentry. Only Nginx error log is currently supported, but extending the library to support more log files is planned.
To install sentrylogs you can use pip or easy_install:
$ pip install sentrylogs
$ easy_install sentrylogs
This will install the module and will provide a new console command:
$ sentrylogs -h
usage: sentrylogs [-h] [--sentryconfig SENTRYCONFIG] [--sentrydsn SENTRYDSN]
[--daemonize] [--follow FOLLOW]
[--nginxerrorpath NGINXERRORPATH]
Send logs to Django Sentry.
optional arguments:
-h, --help show this help message and exit
--sentryconfig SENTRYCONFIG, -c SENTRYCONFIG
A configuration file (.ini, .yaml) of some Sentry
integration to extract the Sentry DSN from
--sentrydsn SENTRYDSN, -s SENTRYDSN
The Sentry DSN string (overrides -c)
--daemonize, -d Run this script in background
--follow FOLLOW, -f FOLLOW
Which logs to follow, default ALL
--nginxerrorpath NGINXERRORPATH, -n NGINXERRORPATH
Nginx error log path
We need to provide a Sentry DSN to send messages to the Sentry server. There are 3 options to do this:
- Use the
--sentryconfig
command line argument to read the configuration file of your Sentry integration, or - Use the
--sentrydsn
command line argument to specify the DSN directly, or - Provide an environment variable.
$ sentrylogs --sentryconfig /opt/myapp/config/pyramid.ini
$ sentrylogs --sentrydsn 'protocol://public:secret@example.com/#'
$ export SENTRY_DSN='protocol://public:secret@example.com/#' && sentrylogs
By default sentrylogs will assume the nginx log at /var/log/nginx/error.log
.
You can change this using the --nginxerrorpath
argument.
If you use --daemonize
the command will daemonize itself and run in
background.
Please open an issue to discuss your plans for a pull request. After writing code make sure your changes pass our quality gate before you push.
# list all tox targets
tox -lv
# run all linting and tests
tox
# run tests just for Python 3.8
# (e.g. if you don't have all Pythons installed via pyenv)
tox -e py38
Please write tests! Test coverage is still low and the code quality needs to improve. Please help by adding tests with each contribution you make!