Skip to main content

Flask_OsloLog

Build Status Coverage Status

Flask Oslo Log is a WSGI Middleware and Flask Extension intended to provide logging via the Oslo-Log package inside Flask.

Installation

  1. git clone {thisrepo}

  2. python setup.py install

Getting Started with Flask Oslo Log

Flask Oslo Log is a Flask Extension which adds request logging via oslo.log, as well as exposing an arbitrary logger to oslo.log similarly to the standard app logger.

Configuring the Extension

flask_oslolog requires no configuration of it’s own, but you may wish to utilize the upstream configuration options of oslo.log to configure log file location, etc.

A basic configuration might look like this:

[DEFAULT]
debug=True
log_file=/var/log/yourapp/flask.log

Initializing the Extension

Simply wrap the application object during instantiation:

from flask import Flask

from flask_oslolog import OsloLog

app = Flask(__name__)
log = OsloLog(app)

if __name__ == "__main__":  # pragma: nocover
    app = create_app(app_name=__name__)
    app.run(host="0.0.0.0", port=5000

Accessing the extension

Once the extension is intialized, you will notice that, by default, request logging has been enabled. In your log file you will begin to see messages like this:

2017-01-19 18:30:26.654 2082 INFO flask\_oslog.middleware \[-\] 1.2.3.4 my_user Confirmed "GET /resource/1" status: 200 len: 8317

Additionally, arbitrary logging will become available:

from flask import Flask

from flask_oslolog import OsloLog

app = Flask(__name__)
log = OsloLog(app)

@app.route("/")
log.logger.warn("Someone is accessing the root!")
return "access granted"

if __name__ == "__main__":  # pragma: nocover
    app = create_app(app_name=__name__)
    app.run(host="0.0.0.0", port=5000

Initializing the Extension in an Application Factory app

As with all flask extensions, it is also accessible in an application Factory setting by initializing the extension separately from it’s instantiation:

from flask import Flask

from flask_oslolog import OsloLog

log = OsloLog()

def create_app(app_name):
    app = Flask(app_name)
    log.init_app(app)

    return app


if __name__ == "__main__":  # pragma: nocover
    app = create_app(app_name=__name__)
    app.run(host="0.0.0.0", port=5000)

Metadata

Release files for flask-oslolog 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flask-oslolog 0.1
File Size Uploaded Provenance
flask_oslolog-0.1.tar.gz 5.7 kB Without provenance Details

Release files / flask_oslolog-0.1.tar.gz

Download URL flask_oslolog-0.1.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
724c55bd74b3e7fa2bc31d16eb8a6e6d866fae9ff3b9d9bc08480466ebc5a5f2
BLAKE2b-256 checksum
How to use checksums
a762fec02ce761b548b1289680bb1be1aa0bce2b2c4017d5b31bd6c67c78aef9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for flask-oslolog 0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page