Skip to main content

This package provides a python logger which is simple to use and logs structured logs per default for the gcp.

Project description

python-gcp-logger

This repo provides a python logger wrapper for structured logs on gcp.

Installation

pip install python-custom-logger
or
poetry add python-custom-logger

Usage

from custom_logger.logger import CustomStructuredLogger

log_to_cloud: bool = True if <any condition to check if in cloud service env> else False
log_to_console: bool = not log_to_cloud
logger: CustomStructuredLogger = CustomStructuredLogger(
    project_id=<GCP_PROJECT_ID>,
    name="MyLogger",
    log_to_console=log_to_console,
    log_to_cloud=log_to_cloud,
)

logger.info(message="helloworld")
logger.info(message={"hello": "world"})
logger.error(message="helloworld")
logger.error(message={"hello": "world"})
logger.warning(message="helloworld")
logger.warning(message={"hello": "world"})

# Using additional attributes:
logger.info(message={"hello": "world"}, attributes {"foo": "bar"})

TODOs

  • add tests
  • replace google logger with python logger using structured std out log

Project details


Download files

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

Source Distribution

python_custom_logger-1.0.4.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_custom_logger-1.0.4-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file python_custom_logger-1.0.4.tar.gz.

File metadata

  • Download URL: python_custom_logger-1.0.4.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.0 CPython/3.10.12 Linux/6.5.0-1022-azure

File hashes

Hashes for python_custom_logger-1.0.4.tar.gz
Algorithm Hash digest
SHA256 25c1b12f2da14032f542a4f090912f5461f087a4e463ed66a9220d4ee574c473
MD5 8f90d33eedede0b80e6bed96a9d581a7
BLAKE2b-256 870cdadcbda1c6666fd490edc1fc660604d2e4d556f683d60daf4f199e3db087

See more details on using hashes here.

File details

Details for the file python_custom_logger-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: python_custom_logger-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.0 CPython/3.10.12 Linux/6.5.0-1022-azure

File hashes

Hashes for python_custom_logger-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a07dd2f888113bb663b56db7df7c07b83917fc68a3c0a633e5ac218729a14e72
MD5 794906066a88ce0e2085e2876100d015
BLAKE2b-256 5d939126ca15c02784bdfe2ecaed3a435d82fae129d712c857a212a48e966bf6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page