Skip to content

synchrolog/synchrolog-flask

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Synchrolog

Installation

pip install -r git+https://github.com/synchrolog/synchrolog-flask.git@master

Usage

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!!!')

Configuration

  • 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.

Note

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.

For running tests

python3 -m venv .env
source .env/bin/activate
pip install -r requirements.txt
python -m unittest tests/test.py

About

Synchrolog library for Flask

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages