Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mitodl/flask-log
This is a handy flask extension for setting up logging for your application that is super simple to setup.
https://github.com/mitodl/flask-log
Last synced: 6 days ago
JSON representation
This is a handy flask extension for setting up logging for your application that is super simple to setup.
- Host: GitHub
- URL: https://github.com/mitodl/flask-log
- Owner: mitodl
- License: bsd-2-clause
- Created: 2015-03-31T22:17:58.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-10-20T13:38:04.000Z (about 1 year ago)
- Last Synced: 2024-12-03T15:06:44.284Z (21 days ago)
- Language: Python
- Size: 7.81 KB
- Stars: 12
- Watchers: 13
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
Flask-Log
---------.. image:: https://img.shields.io/travis/mitodl/flask-log.svg
:target: https://travis-ci.org/mitodl/flask-log
.. image:: https://img.shields.io/coveralls/mitodl/flask-log.svg
:target: https://coveralls.io/r/mitodl/flask-log
.. image:: https://img.shields.io/github/issues/mitodl/flask-log.svg
:target: https://github.com/mitodl/flask-log/issues
.. image:: https://img.shields.io/pypi/dm/flask-log.svg
:target: https://pypi.python.org/pypi/flask-log/0.1.0
.. image:: https://img.shields.io/pypi/v/flask-log.svg
:target: https://pypi.python.org/pypi/flask-log/0.1.0
.. image:: https://img.shields.io/badge/license-BSD-blue.svg
:target: https://github.com/mitodl/flask-log/blob/master/LICENSEThis is a handy flask extension for setting up logging for your
application that is super simple to setup. A basic example is:.. code-block:: python
import flask
from flask.ext.log import Loggingapp = flask.Flask(__name__)
app.config['FLASK_LOG_LEVEL'] = 'DEBUG'
flask_log = Logging(app)
app.logger.debug('Testing a debug message')
So the level of logging is configurable through regular flask
configuration methods. Additionally, since we are setting up the root
logger, you can use whatever logger you want as you aren't restricted
to the flask application logger. i.e. something like:.. code-block:: python
import logging
log = logging.getLogger('my-special-logger')
log.critical('Oh my!')will also keep the formatter and level if the extensions has been
initialized anywhere.Features
========- Sets up syslog handling to either ``/dev/log``, ``/var/run/syslog``,
or ``127.0.0.1`` on UDP port 514 depending on what is available.
- Adds a log formatter packed with information and by default produces
output like: ``[2015-03-31 18:10:17,816] CRITICAL 42282 [__main__]
example.py:7 - [my_hostname] - Hi``
- Full code coverage
- The log formatter can be overidden with something like:.. code-block:: python
flask_logger = Logging(app)
flask_logger.set_formatter('Log message follows: %(message)s')Links
`````- `documentation `_
- `development version `_