Code Monkey home page Code Monkey logo

flask-log's Introduction

Flask-Log

This is a handy flask extension for setting up logging for your application that is super simple to setup. A basic example is:

import flask
from flask.ext.log import Logging

app = 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:

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:

    flask_logger = Logging(app)
    flask_logger.set_formatter('Log message follows: %(message)s')

Links

flask-log's People

Contributors

bdero avatar carsongee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.