Skip to main content

Simple logging decorator for Flask.

Project description

flask-logging-decorator

Build Status

This is a deadly simple logging decorator for Flask. This is highly inspired by canassa/flask-trace.

Compatibility

This is tested with Python3.5, 3.6 and Flask1.0.2.

Installation

pip install flask-logging-decorator

Run the test

This modules uses pytest. You can install it before running the test.

python -m pytest -v

Usage

Import and put it as the decorator function.

import logging

from flask_logging_decorator import trace
from flask import Flask

app = Flask(__name__)

@trace(logging.ERROR)
@app.route('/')
def index():
    return 'hello'

...

The application should show the logging message like following.

[2018-05-17 19:01:31,468] ERROR in __init__: trace_uuid=cf66d343-06f4-49cb-a680-59ba9ec77570 method=GET func_name=index func_args: query_args:foo='bar' baz='qux' post_values: trace_info:trace_pathname=main.py trace_lineno=12

If you don't pass the logging level to @trace, it will use the Flask's application logger.

License

MIT license, see the LICENSE file. You can use this library in open source projects and commercial products.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flask_logging_decorator-0.0.5.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flask_logging_decorator-0.0.5-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file flask_logging_decorator-0.0.5.tar.gz.

File metadata

File hashes

Hashes for flask_logging_decorator-0.0.5.tar.gz
Algorithm Hash digest
SHA256 07c28af5bed6d37f19e8f430d87a41c0636f131cd1ca3adb7ef83ab80beb607f
MD5 013565993301a81aef75714750efa52e
BLAKE2b-256 44d146a94d15b3ae149d1f53fef37c2b02491e4ecd70d64b9820a0fccb2ccfc4

See more details on using hashes here.

File details

Details for the file flask_logging_decorator-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for flask_logging_decorator-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 43d88f7ab27c65d619fbf35ce7ec4f1c66097a32173d0ae896b60cc254fa4ccf
MD5 c17d305b10802e886ade70cc5a731ffe
BLAKE2b-256 ca4430e500c9a074896252dce4cd8dc72433a87f81fe32cd4f91c7b9bfcb7552

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page