Metadata-Version: 2.1
Name: casavo-log-formatter
Version: 1.0.3
Summary: A pre-configured JSON formatter for the Casavo logging format
Author-email: Casavo <tech.internals@casavo.com>
Maintainer-email: Casavo <tech.internals@casavo.com>
License: Copyright 2023 Casavo Management S.p.A.
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall 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/casavo/casavo-log-formatter
Project-URL: Bug Reports, https://github.com/casavo/casavo-log-formatter/issues
Project-URL: Source, https://github.com/casavo/casavo-log-formatter
Keywords: casavo,logging,json
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Topic :: System :: Logging
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Provides-Extra: orjson
Provides-Extra: dev
License-File: LICENSE.txt

# casavo-log-formatter

An utility library that exposes a pre-configured log formatter for the Casavo JSON logging format.

## Installation

`pip install casavo-log-formatter`, or `pip install casavo-log-formatter[orjson]` if you prefer using `orjson` as a json serializer.

## Usage

Referring to https://docs.python.org/3/library/logging.config.html#logging-config-dictschema,
we suggest to configure your logging `dictConfig` by adding those 2 keys:

```python
formatters = {
    "simple": {
        "format": "%(levelname)s %(message)s",
        "datefmt": "%H:%M:%S",
    },
    "standard": {
        "class": "casavo_log_formatter.formatters.CasavoJsonFormatter"
    },
}
```

```python
handlers = {
    "stdout": {
        "level": "DEBUG",
        "class": "logging.StreamHandler",
        "formatter": "standard"
        if settings.ENVIRONMENT in ["staging", "production"]  # or whatever you use to specify the env
        else "simple",
    },
}
```

This will configure a simple log format for dev and the fully featured formatter for staging + dev.

## Development

* Have a local python >=3.9
* `python -m venv .venv`
* `pip install -r requirements.txt`
* `pre-commit install`
* `pip install -e .`

### Test

`make test` or `nox` to launch the test matrix against Python 3.9, 3.10, 3.11

### Uploading on PyPI

* `make upload`
