Metadata-Version: 2.1
Name: flask-logging-decorator
Version: 0.0.3
Summary: Simple logging decorator for Flask.
Home-page: https://github.com/sgykfjsm/flask-logging-decorator
Author: Shigeyuki Fujishima
Author-email: shigeyuki.fujishima@gmail.com
License: UNKNOWN
Keywords: flask logging decorator
Platform: UNKNOWN
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.6
Requires-Python: >=3.5, !=2.*.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
Description-Content-Type: text/markdown
Provides-Extra: dev
Provides-Extra: dev
Requires-Dist: attrs; extra == 'dev'
Requires-Dist: click; extra == 'dev'
Requires-Dist: configparser; extra == 'dev'
Requires-Dist: enum34; extra == 'dev'
Requires-Dist: flake8; extra == 'dev'
Requires-Dist: flask; extra == 'dev'
Requires-Dist: itsdangerous; extra == 'dev'
Requires-Dist: jinja2; extra == 'dev'
Requires-Dist: markupsafe; extra == 'dev'
Requires-Dist: mccabe; extra == 'dev'
Requires-Dist: more-itertools; extra == 'dev'
Requires-Dist: mypy; extra == 'dev'
Requires-Dist: pluggy; extra == 'dev'
Requires-Dist: py; extra == 'dev'
Requires-Dist: pycodestyle; extra == 'dev'
Requires-Dist: pyflakes; extra == 'dev'
Requires-Dist: pytest-mock; extra == 'dev'
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: six; extra == 'dev'
Requires-Dist: typed-ast; extra == 'dev'
Requires-Dist: werkzeug; extra == 'dev'

# flask-logging-decorator

[![Build Status](https://travis-ci.org/sgykfjsm/flask-logging-decorator.svg?branch=master)](https://travis-ci.org/sgykfjsm/flask-logging-decorator)

This is a deadly simple logging decorator for Flask. This is highly inspired by [canassa/flask-trace](https://github.com/canassa/flask-trace).

## Compatibility

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

## Installation

```bash
pip install flask-logging-decorator
```

## Run the test

This modules uses [pytest](http://pytest.org/latest/). You can install it before running the test.

```bash
python -m pytest -v
```

## Usage

Import and put it as the decorator function.

```python
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.

```text
[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
```

Note that don't forget to pass the log level argument. You have to pass the appropriate logging level. Otherwise, this decorator never output any messages.

## License

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


