Metadata-Version: 2.4
Name: clarity-api-sdk-python
Version: 0.2.11
Summary: A Python SDK to connect to the CTI Clarity API server.
Author-email: "Chesapeake Technology Inc." <support@chesapeaketech.com>
Project-URL: Homepage, https://github.com/chesapeake-tech/clarity-api-sdk-python
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.28.1
Requires-Dist: brotli
Requires-Dist: h2
Requires-Dist: httpx_auth>=0.23.1
Requires-Dist: httpx-retries>=0.4.5
Requires-Dist: structlog
Provides-Extra: brotli
Requires-Dist: httpx[brotli]>=0.28.1; extra == "brotli"
Provides-Extra: http2
Requires-Dist: httpx[http2]>=0.28.1; extra == "http2"

# Clarity API SDK for Python

[![PyPI - Downloads](https://badge.fury.io/py/clarity-api-sdk-python.svg)](https://pypi.org/project/clarity-api-sdk-python/)
[![Downloads](https://pepy.tech/badge/clarity-api-sdk-python)](ttps://test.pypi.org/project/clarity-api-sdk-python/)
![python](https://img.shields.io/badge/python-3.11%2B-blue)

A Python SDK for connecting to the CTI API server, with structured logging included.

## Installation

```bash
pip install clarity-api-sdk-python
```

## Logging

Logging support is built with [structlog](https://pypi.org/project/structlog/).

Set the root logger by setting the environment variable `LOG_LEVEL`. Otherwise, the default root logging is set to `INFO`.

```python
"""Example"""

import logging

from cti.logger import initialize_logger, get_logger, ExternalLoggerConfig

initialize_logger(
    external_logger_configurations=[
        ExternalLoggerConfig(name="urllib3"),
        ExternalLoggerConfig(name="httpcore"),
        ExternalLoggerConfig(name="httpx"),
        ExternalLoggerConfig(name="httpx_auth"),
        ExternalLoggerConfig(name="httpx_retries"),
    ],
    handlers=[logging.FileHandler("app.log")]
)

logger_a = get_logger("logger_a")
logger_b = get_logger("logger_b", "WARNING")

# root_logger = logging.getLogger()
# root_logger.setLevel("DEBUG")

logger_a.info("This is info message from logger_a")
logger_a.critical("This is critical message from logger_a")

# Dynamically change the log level of logger_a to WARNING
print("\nChanging logger_a level to WARNING...\n")
logging.getLogger("logger_a").setLevel(logging.WARNING)

logger_a.info("This info message from logger_a should NOT be visible.")
logger_a.warning("This is a new warning message from logger_a.")

logger_b.info("This info message from logger_b should NOT be visible.")
logger_b.warning("This is warning message from logger_b")
```
