This project requires Python 3.6 and Flask 0.12
To install it without Sentry support, simply run
pip install flask-logger
To install it with Sentry support, run
pip install flask-logger[Sentry]
Import it and wrap app
from flask import Flask
from flask_logger import Logger
app = Flask(__name__)
logger = Logger(app)
You can set the default logging level on your app with the config value LOG_LEVEL
.
If you use Sentry with your project, you can setup Sentry logging by adding
the SENTRY_DSN
configuration value. Your DSN can be retrieved from your project in Sentry.
If you do use Sentry, you may also want to specify an ENV
(dev, staging, qa, prod, etc) in your
app's config so that the correct environment information can be sent to Sentry.
You can modify the console output format with the configuration values LOG_FORMAT_CONSOLE
and
LOG_FORMAT_TIME
. See the Python 3
logging Formatter docs
for more info.
This project was written and tested with Python 3. Our builds currently only test Python 3.6.
On a mac you can use the following commands to get up and running.
brew install python3
otherwise run
brew upgrade python3
to make sure you have an up to date version.
This project uses pip-tools for dependency management. Install pip-tools
pip3 install pip-tools
setup the project env
python -m venv venv
pip install -r requirements.txt -r requirements-dev.txt
Make sure the following environment variables are set
export PYTHONPATH=`pwd`
Then load your virtualenv
source venv/bin/activate
./linters.sh && coverage run --source=flask_logger/ setup.py test
We have a pre-commit hook each dev needs to setup. You can symlink it to run before each commit by changing directory to the repo and running
cd .git/hooks
ln -s ../../pre-commit pre-commit