[go: up one dir, main page]

Skip to content
This repository has been archived by the owner on Jul 20, 2021. It is now read-only.
/ logicipi Public archive

A logging util for Python applications running on GCP

License

Notifications You must be signed in to change notification settings

infarm/logicipi

Repository files navigation

LoGiCiPi

WARNING: This project is no longer maintained ❄️

A tiny wrapper on structlog and gcloud logging library for applications running inside GCP.

Works for both cloud functions and containers.

Quickstart

Containers

LoGiCiPi provides a nice util, configure_structlog, with a pre-configured logging.

You only need to import it and then run it.

from logicipi import configure_structlog
from structlog import get_logger

configure_structlog()

log = get_logger()

log.info("Hi There")
# {"event": "Hello There", "logger": "__main__", "timestamp": "2020-06-09T13:24:43.481664Z", "severity": "info"}

Cloud functions

# file main.py
from logicipi import gcp_logger

log = gcp_logger(function_name="my-function-name", region="my-region").get_logger()
# you can omit `function_name` and `region`
# if you have `FUNCTION_NAME` and `FUNCTION_REGION`
# as env variables

log.info("Hello There", value=1)

# file another.py
from logicipi import gcp_logger

log = gcp_logger().get_logger()

log.error("Hello There", value=1)

gcp_logger returns a singleton, so the object can be instantiated multiple times.

The auth flow relies on the GCloud Auth flow, you can read more here.

About

A logging util for Python applications running on GCP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages