> ## Documentation Index
> Fetch the complete documentation index at: https://systematica.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Loggers

> systematica.generic.loggers

## Variables

* `custom_logger: logging.Logger`: A custom logger instance for the Systematica library.

## `build_logger`

```python theme={null}
build_logger(
    logger_name: str,
) ‑> logging.Logger
```

Build a custom logger with a RichHandler for better formatting.
This logger will not propagate messages to the root logger.

**Parameters**:

| Name          | Type  | Default | Description                       |
| ------------- | ----- | ------- | --------------------------------- |
| `logger_name` | `str` | `--`    | The name of the logger to create. |

**Returns**:

| Type             | Description                                      |
| ---------------- | ------------------------------------------------ |
| `logging.Logger` | A configured logger instance with a RichHandler. |

## `UTCFormatter`

```python theme={null}
UTCFormatter(
    fmt=None,
    datefmt=None,
    style='%',
    validate=True,
    *,
    defaults=None,
)
```

A custom logging formatter that formats timestamps in UTC.

Initialize the formatter with specified format strings.

Initialize the formatter either with the specified format string, or a
default as described above. Allow for specialized date formatting with
the optional datefmt argument. If datefmt is omitted, you get an
ISO8601-like (or RFC 3339-like) format.

Use a style parameter of `%`, `{` or `$` to specify that you want to
use one of `%`-formatting, `str.format` (`{}`) formatting or
`string.Template` formatting in your format string.

**Parameters**:

| Name       | Type   | Default | Description                                                                                                                             |
| ---------- | ------ | ------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| `fmt`      | `str`  | `None`  | The format string for the log messages. If `None`, a default format is used.                                                            |
| `datefmt`  | `str`  | `None`  | A format string for the date and time in the log messages. If `None`, defaults to `ISO` format.                                         |
| `style`    | `str`  | `%`     | The style of formatting to use. Can be one of `%`, `{`, or `$`. Defaults to `%`.                                                        |
| `validate` | `bool` | `True`  | If `True`, validate the format string against the specified style.                                                                      |
| `defaults` | `dict` | `None`  | A dictionary of default values for the format string. This is used to provide default values for any placeholders in the format string. |

**Raises**:

| Type         | Description                                              |
| ------------ | -------------------------------------------------------- |
| `ValueError` | If the format string is invalid for the specified style. |

### Ancestors

* `logging.Formatter`

### Methods

#### `formatTime`

```python theme={null}
formatTime(
    self,
    record,
    datefmt=None,
)
```

Convert the record's creation timestamp to a UTC datetime object.
If a datefmt is provided, format the datetime according to that format.

**Parameters**:

| Name      | Type                | Default | Description                                                                |
| --------- | ------------------- | ------- | -------------------------------------------------------------------------- |
| `record`  | `logging.LogRecord` | `--`    | The log record containing the timestamp to format.                         |
| `datefmt` | `str`               | `None`  | A format string for the datetime. If not provided, defaults to ISO format. |

**Returns**:

| Type  | Description                          |
| ----- | ------------------------------------ |
| `str` | The formatted timestamp as a string. |

## `Logger`

```python theme={null}
Logger(
    template_name: str = None,
)
```

A logger class that provides logging functionality for different strategies.

Initialize the Logger.

**Parameters**:

| Name            | Type  | Default | Description                                                                                                 |
| --------------- | ----- | ------- | ----------------------------------------------------------------------------------------------------------- |
| `strategy_name` | `str` | `None`  | The name of the strategy for which the logger is created. If not provided, the default root logger is used. |

### Descendants

* `systematica.generic.loggers.TimeRotatingLogger`
* `systematica.tools.messengers.base.BaseMessenger`

### Static methods

#### `get_logger_instance`

```python theme={null}
get_logger_instance(
    strategy_name: str,
) ‑> logging.Logger
```

Get a logger instance for a specific strategy.

**Parameters**:

| Name            | Type  | Default | Description                                               |
| --------------- | ----- | ------- | --------------------------------------------------------- |
| `strategy_name` | `str` | `--`    | The name of the strategy for which the logger is created. |

**Returns**:

| Type             | Description                                              |
| ---------------- | -------------------------------------------------------- |
| `logging.Logger` | A logger instance configured for the specified strategy. |

### Methods

#### `info`

```python theme={null}
info(
    self,
    msg: str,
)
```

Log a message at the `INFO` level.

**Parameters**:

| Name  | Type  | Default | Description         |
| ----- | ----- | ------- | ------------------- |
| `msg` | `str` | `--`    | The message to log. |

#### `error`

```python theme={null}
error(
    self,
    msg: str,
)
```

Log a message at the `ERROR` level.

**Parameters**:

| Name  | Type  | Default | Description         |
| ----- | ----- | ------- | ------------------- |
| `msg` | `str` | `--`    | The message to log. |

#### `warning`

```python theme={null}
warning(
    self,
    msg: str,
)
```

Log a message at the `WARNING` level.

**Parameters**:

| Name  | Type  | Default | Description         |
| ----- | ----- | ------- | ------------------- |
| `msg` | `str` | `--`    | The message to log. |

## `TimeRotatingLogger`

```python theme={null}
TimeRotatingLogger(
    template_name: str = None,
)
```

A logger class which rotates at midnight.

Initialize the Logger.

**Parameters**:

| Name            | Type  | Default | Description                                                                                                 |
| --------------- | ----- | ------- | ----------------------------------------------------------------------------------------------------------- |
| `strategy_name` | `str` | `None`  | The name of the strategy for which the logger is created. If not provided, the default root logger is used. |

### Ancestors

* `systematica.generic.loggers.Logger`

### Static methods

#### `get_logger_instance`

```python theme={null}
get_logger_instance(
    strategy_name: str,
) ‑> logging.Logger
```

Get `TimedRotatingFileHandler` that rotates at midnight.

**Parameters**:

| Name            | Type  | Default | Description                                               |
| --------------- | ----- | ------- | --------------------------------------------------------- |
| `strategy_name` | `str` | `--`    | The name of the strategy for which the logger is created. |

**Returns**:

| Type             | Description                                              |
| ---------------- | -------------------------------------------------------- |
| `logging.Logger` | A logger instance configured for the specified strategy. |
