Flask-DatastoreLogger
A logging interface for Google Cloud Datastore
Installation
Add this line to your application's requirements.txt
Flask-DatastoreLogger
And then execute:
$ pip install -r requirements.txt
Or install it yourself as:
$ pip install Flask-DatastoreLogger
Usage
Using DatastoreLogger is dead simple. First set your GOOGLE_APPLICATION_CREDENTIALS environment variable to point at a valid JSON creds file.
$ export GOOGLE_APPLICATION_CREDENTIALS=/path/to/creds.json
The following snippet should get you coding
import logging
from flask import Flask
from DatastoreLogger import DatastoreLog, DatastoreLogHandler
from PubSubDecorator import PubSubDecorator
app = Flask(__name__)
app.pubsub = PubSubDecorator(app)
@app.pubsub.subscribe(
subscription='run_task'
topic='task_queue',
route='/run_task',
methods=['POST']
)
def run_task(message, *args, **kwargs):
task_id = message.get('task_id')
task_logger = logging.getLogger('task_log_{0}'.format(task_id))
handler = DatastoreLogHandler('task_log', task_id)
task_logger.addHandler(handler)
task_logger.setLevel(logging.DEBUG)
task_logger.info('Starting Task #{0}'.format(task_id))
# process task actions logging messages with task_logger
return '', 200
@app.route('/task_log/<int:task_id>', methods=['GET'])
def task_log(task_id):
log = DatastoreLog('task_log', task_id)
return log.stream_response()
Testing
$ pytest -s --show-capture=no tests.py
Metadata
Release files for Flask-DatastoreLogger 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| Flask-DatastoreLogger-0.0.3.tar.gz | 3.2 kB | Without provenance | Details for Flask-DatastoreLogger-0.0.3.tar.gz |
Release files / Flask-DatastoreLogger-0.0.3.tar.gz
| Download URL | Flask-DatastoreLogger-0.0.3.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b374329cb940728639a395c1111bea1a4ff99c0dce19bd8ee723287cd7b0ea2a
|
|
BLAKE2b-256 checksum How to use checksums |
1829edbae8039d2938b0c2242133bba6433f7b6c54f2f32881f01ea51efa1331
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for Flask-DatastoreLogger 0.0.3
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.