Skip to main content

Google Cloud Logger Formatter

Project description


CircleCI PyPI version Maintainability Test Coverage

Python log formatter for Google Cloud according to v2 specification using python-json-logger formatter

Inspired by Elixir's logger_json



    pipenv install google_cloud_logger 


    pip install google_cloud_logger 


    "version": 1,
    "formatters": {
        "json": {
            "()": "google_cloud_logger.GoogleCloudFormatter",
            "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"]
import logging

from logging import config

config.dictConfig(LOG_CONFIG) # load log config from dict

logger = logging.getLogger("root") # get root logger instance"farofa", extra={"extra": "extra"}) # log message with extra arguments  

Example output:

{"timestamp": "2018-11-03T22:05:03.818000Z", "severity": "INFO", "message": "farofa", "labels": {"type": "python-application", "name": "Example Application"}, "metadata": {"userLabels": {"extra": "extra"}}, "sourceLocation": {"file": "<ipython-input-9-8e9384d78e2a>", "line": 1, "function": "<module>"}}


Thanks @thulio, @robsonpeixoto, @ramondelemos

Project details

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
google_cloud_logger-0.2.1-py3-none-any.whl (6.7 kB) Copy SHA256 hash SHA256 Wheel py3
google_cloud_logger-0.2.1.tar.gz (4.6 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page