pip install -r git+https://github.com/synchrolog/synchrolog-flask.git@master
Add access token to your application config
app.config['SYNCHROLOG_ACCESS_TOKEN'] = '1234'Call function init from synchrolog_flask module
synchrolog_flask.init(app, use_queue=True, level=logging.INFO)Full example
import logging
import synchrolog_flask
from flask import Flask
app = Flask(__name__)
app.config['SYNCHROLOG_ACCESS_TOKEN'] = '123456'
synchrolog_flask.init(app, use_queue=True)
# Disable default logging
logging.getLogger('werkzeug').setLevel(logging.ERROR)
logger = app.logger
@app.route('/')
def hello():
logger.info('HELLO')
logger.error('ALOHA',)
raise ValueError('EXCEPTION!!!')- use_queue: bool (default true and recommended) - if value is true than all logs to Synchrolog will send in another thread with queue without blocking current request. if values is false, than every logger calls will block current request and will wait outcoming request tp Synchrolog
- level: int (default logging.root.level) - level of all logs in system.
if FLASK_DEBUG is true any exceptions will be handled by flask and
converted to page with stacktrace and status equal to 200, so this library doesn't
catch request exception in debug mode, so recommended way is to use this library only
in production mode.
python3 -m venv .env
source .env/bin/activate
pip install -r requirements.txt
python -m unittest tests/test.py