-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: Update to google_cloud_logger v0.1.0 (#1)
* feature: Update to google_cloud_logger v0.1.0 * chore: Bump lib version to 0.1.0
- Loading branch information
Showing
8 changed files
with
182 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import logging | ||
from logging import config | ||
|
||
from flask import Flask, request, g | ||
from flask_google_cloud_logger import FlaskGoogleCloudLogger | ||
|
||
LOG_CONFIG = { | ||
"version": 1, | ||
"formatters": { | ||
"json": { | ||
"()": "flask_google_cloud_logger.FlaskGoogleCloudFormatter", | ||
"application_info": { | ||
"type": "python-application", | ||
"name": "Example Application" | ||
}, | ||
"format": "[%(asctime)s] %(levelname)s in %(module)s: %(message)s" | ||
} | ||
}, | ||
"handlers": { | ||
"json": { | ||
"class": "logging.StreamHandler", | ||
"formatter": "json" | ||
} | ||
}, | ||
"loggers": { | ||
"root": { | ||
"level": "INFO", | ||
"handlers": ["json"] | ||
}, | ||
"werkzeug": { | ||
"level": "WARN", # Disable werkzeug hardcoded logger | ||
"handlers": ["json"] | ||
} | ||
} | ||
} | ||
|
||
config.dictConfig(LOG_CONFIG) # load log config from dict | ||
logger = logging.getLogger("root") # get root logger instance | ||
app = Flask("test_app") | ||
FlaskGoogleCloudLogger(app) | ||
|
||
|
||
@app.route("/") | ||
def hello_world(): | ||
return "Hello, World!" | ||
|
||
|
||
@app.teardown_request | ||
def log_request_time(_exception): | ||
logger.info( | ||
f"{request.method} {request.path} - Sent {g.response.status_code}" + | ||
" in {g.request_time:.5f}ms") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
from setuptools import setup | ||
|
||
__VERSION__ = "0.1.0" | ||
|
||
setup( | ||
name="flask_google_cloud_logger", | ||
version="0.0.2", | ||
version=__VERSION__, | ||
description="Google Cloud Log Formatter for Flask", | ||
url="http://github.com/rai200890/flask_google_cloud_logger", | ||
author="Raissa Ferreira", | ||
author_email="[email protected]", | ||
license="MIT", | ||
packages=["flask_google_cloud_logger"], | ||
install_requires=[ | ||
"google_cloud_logger>=0.0.2", | ||
"google_cloud_logger>=0.1.0", | ||
"flask>=1.0", | ||
], | ||
classifiers=[ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters