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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for python_custom_logger-1.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ba3f15ae7702291bea320eb1bf646df372f1b7654054ccdbc8f7dccddade462 |
|
MD5 | bb5ec03eeb3a4cee02958fa0d17288fd |
|
BLAKE2b-256 | ec23156c6a9f7f4148376f2a5bc35d71debf4643f14e92affdde6ce2572cbeaa |
Close
Hashes for python_custom_logger-1.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffbeae8425d9fbdbc88a6d2d36594ac102115b93d59bcb4d251d7a045fec193e |
|
MD5 | ac8dd25f8fafcc898861c5cdb854c2d1 |
|
BLAKE2b-256 | 9321f7bf3babcf2815b52b35671bb3a1814c978bd2b06f62eed4ce0865eb6213 |