Metadata-Version: 2.1
Name: python-custom-logger
Version: 1.0.0
Summary: This package provides a python logger which is simple to use and logs structured logs per default for the gcp.
Home-page: https://github.com/Depaccu/python-custom-logger
License: MIT
Keywords: gcp,logger,structured,logs
Author: JUNGELEN
Author-email: jeffrey_ungelenk@icloud.com
Requires-Python: >=3.11,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: google-cloud-logging (>=3.5.0,<4.0.0)
Project-URL: Repository, https://github.com/Depaccu/python-custom-logger
Description-Content-Type: text/markdown

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

## Installation
```
pip isntall 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
