Metadata-Version: 2.4
Name: oci-log-handler
Version: 0.1.1
Summary: A buffered Python logging handler for Oracle Cloud Infrastructure Logging.
Author: KC Flynn
License: Copyright (c) 2022-2026, Oracle and/or its affiliates.
        
        The Universal Permissive License (UPL), Version 1.0
        
        Subject to the condition set forth below, permission is hereby granted to any
        person obtaining a copy of this software, associated documentation and/or data
        (collectively the "Software"), free of charge and under any and all copyright
        rights in the Software, and any and all patent rights owned or freely
        licensable by each licensor hereunder covering either (i) the unmodified
        Software as contributed to or provided by such licensor, or (ii) the Larger
        Works (as defined below), to deal in both
        
        (a) the Software, and
        (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
        one is included with the Software (each a “Larger Work” to which the Software
        is contributed by such licensors),
        
        without restriction, including without limitation the rights to copy, create
        derivative works of, display, perform, and distribute the Software and make,
        use, sell, offer for sale, import, export, have made, and have sold the
        Software and the Larger Work(s), and to sublicense the foregoing rights on
        either these or other terms.
        
        This license is subject to the following condition:
        
        The above copyright notice and either this complete permission notice or at
        a minimum a reference to the UPL must be included in all copies or
        substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Project-URL: Homepage, https://github.com/flynnkc/oci-log-handler
Project-URL: Repository, https://github.com/flynnkc/oci-log-handler
Project-URL: Issues, https://github.com/flynnkc/oci-log-handler/issues
Keywords: oci,oracle-cloud,logging,handler
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Universal Permissive License (UPL)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: System :: Logging
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: oci>=2.185.0
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == "dev"
Requires-Dist: twine>=5; extra == "dev"
Dynamic: license-file

# OCI Log Handler

A buffered Python `logging` handler that sends application logs to Oracle Cloud
Infrastructure Logging by using the OCI Python SDK Logging Ingestion client.

Requires Python 3.11 or later.

## Installation

```bash
pip install oci-log-handler
```

## Usage

```python
import logging

import oci
from oci_log_handler import OciLoggingHandler

config = oci.config.from_file()

handler = OciLoggingHandler(
    log_ocid="ocid1.log.oc1..example",
    config=config,
    capacity=100,
)
handler.setFormatter(logging.Formatter("%(levelname)s:%(name)s:%(message)s"))

logger = logging.getLogger("my-app")
logger.setLevel(logging.INFO)
logger.addHandler(handler)

logger.info("Application started")
```

You can also pass an existing OCI Logging Ingestion client:

```python
import logging

import oci
from oci import loggingingestion
from oci_log_handler import OciLoggingHandler

config = oci.config.from_file()
client = loggingingestion.LoggingClient(config)

handler = OciLoggingHandler(
    log_ocid="ocid1.log.oc1..example",
    client=client,
    capacity=100,
)

logger = logging.getLogger("my-app")
logger.addHandler(handler)
```

For signer-based authentication, pass `signer=` when constructing the handler
or create the `LoggingClient` with your signer and pass it as `client=`.

## Delivery behavior

This handler is best-effort and keeps its retry buffer in memory. By default,
failed submissions are restored to the handler's bounded buffer and do not raise
exceptions into the application. If the process exits before a later successful
flush, those buffered records are not durable.

Pass `raise_exceptions=True` if your application should fail fast when OCI
submission fails.
