# logging

Python API: `luxonis_ml.utils.logging`

## Functions

| Name | Description |
| --- | --- |
|
[`deprecated`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/utils/logging.md)
| Mark a function or its parameters as deprecated. |
|
[`log_once`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/utils/logging.md)
| Log a message only once. |
|
[`setup_logging`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/utils/logging.md)
| Set up global logging using loguru and rich. |

### function `deprecated`

```python
def deprecated(
    *args: str,
    suggest: dict[str, str] | None = None,
    additional_message: str | None = None,
    altogether: bool = False,
) -> Callable[[Callable], Callable]
```

Mark a function or its parameters as deprecated.

> **Example**
> ```python
decorator = deprecated(
    "old_arg",
    "another_old_arg",
    suggest={"old_arg": "new_arg"},
    additional_message="Usage of 'old_arg' is discouraged.",
)

def my_func(old_arg, another_old_arg, new_arg=None):
    pass

my_func = decorator(my_func)
my_func("foo")

# DeprecationWarning: Argument 'old_arg'
# in function `my_func` is deprecated and
# will be removed in future versions.
# Use 'new_arg' instead.
# Usage of 'old_arg' is discouraged.
```

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `*args` | `str` | Names of the deprecated parameters. |  |
| `suggest` | `dict[str, str] | None` | Suggested replacement parameters. | `None` |
| `additional_message` | `str | None` | Additional message to append to the warning message. | `None` |
| `altogether` | `bool` | If True, marks the whole function as deprecated. | `False` |

Returns

| Type | Description |
| --- | --- |
| `Callable[[Callable], Callable]` | Decorator that emits deprecation warnings. |

### function `log_once`

```python
def log_once(logger: Callable[[str], None], message: str)
```

Log a message only once.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `logger` | `Callable[[str], None]` | The logger to use. | required |
| `message` | `str` | The message to log. | required |

### function `setup_logging`

```python
def setup_logging(
    *,
    level: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] | None = None,
    file: PathType | None = None,
    use_rich: bool = True,
    pretty_validation_errors: bool = True,
    **kwargs,
)
```

Set up global logging using loguru and rich.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `level` | `Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] | None` | Logging level. If not set, reads from the environment variable `LOG_LEVEL`. | `None` |
| `file` | `PathType | None` | Path to the log file. If provided, logs will be saved to this file. | `None` |
| `use_rich` | `bool` | If True, uses rich for logging. | `True` |
| `pretty_validation_errors` | `bool` | If True, print a readable summary after uncaught pydantic validation errors. | `True` |
| `**kwargs` |  | Additional keyword arguments to pass to `RichHandler`. |  |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If the logging level is invalid. |
