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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25c1b12f2da14032f542a4f090912f5461f087a4e463ed66a9220d4ee574c473
|
|
| MD5 |
8f90d33eedede0b80e6bed96a9d581a7
|
|
| BLAKE2b-256 |
870cdadcbda1c6666fd490edc1fc660604d2e4d556f683d60daf4f199e3db087
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a07dd2f888113bb663b56db7df7c07b83917fc68a3c0a633e5ac218729a14e72
|
|
| MD5 |
794906066a88ce0e2085e2876100d015
|
|
| BLAKE2b-256 |
5d939126ca15c02784bdfe2ecaed3a435d82fae129d712c857a212a48e966bf6
|