Skip to content
main
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Stacklogging

License PyPI version

This small library generates log entries that are understood by Stackdriver Logging. You won't need to authenticate in GCE. The logs emmited will be in JSON schema understood by Stackdriver API and Stackdriver Logging.

Installation

You can use pip to install stacklogging:

pip install stacklogging

Usage

import stacklogging

logger = stacklogging.getLogger()

def sum(a, b):
    logger.info(f"Adding {a} and {b}")
    return a + b

r = sum(2, 4)

This will output a JSON like this one:

{
    "message": "Adding 2 and 4",
    "timestamp": {
        "seconds": 1548239928,
        "nanos": 380779027
    },
    "thread": 140619343472128,
    "severity": "INFO"
}

It is also possible to log extra fields at runtime using the extra parameter.

logger.info("message", extra={"from": "Alice", "to": "Bob"})

Stacklogging will add the extra keys to the final JSON:

{
    "message": "Email sent",
    "timestamp": {
        "seconds": 1548260191,
        "nanos": 256482124
    },
    "thread": 140166127678976,
    "severity": "INFO",
    "from": "Alice",
    "to": "Bob"
}

License

MIT Β© Buffer

About

Python logging integration with Google Cloud Stackdriver API.

Resources

License

Releases

No releases published

Packages

No packages published
You can’t perform that action at this time.