# logging

Python API: `luxonis_ml.utils.logging`

## Functions

### 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.
```

Parameters

 * `*args` (`str`): Names of the deprecated parameters.
 * `suggest` (`dict[str, str] | None`): Suggested replacement parameters.
 * `additional_message` (`str | None`): Additional message to append to the warning message.
 * `altogether` (`bool`): If True, marks the whole function as deprecated.

Returns

 * `Callable[[Callable], Callable]`: Decorator that emits deprecation warnings.

### log_once

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

Log a message only once.

Parameters

 * `logger` (`Callable[[str], None]`): The logger to use.
 * `message` (`str`): The message to log.

### setup_logging

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

Set up global logging using loguru and rich.

Parameters

 * `level` (`Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] | None`): Logging level. If not set, reads from the environment variable `LOG_LEVEL`.
 * `file` (`PathType | None`): Path to the log file. If provided, logs will be saved to this file.
 * `use_rich` (`bool`): If True, uses rich for logging.
 * `**kwargs`: Additional keyword arguments to pass to `RichHandler`.

Raises

 * `ValueError`: If the logging level is invalid.
