# LoggerOnce<!-- -->

Emits each log message at most once, keyed by an explicit string.

Useful for diagnostic warnings that would otherwise spam the log when the same condition recurs (per-request misconfiguration warnings, repeated fallback paths, etc.). Deduplication scope follows the lifetime of the instance - a module-level instance gives process-wide dedup; an attribute on a class gives per-instance dedup.

Safe to call from multiple threads, since the sync client can be used from several threads at once.

## Index[**](#Index)

### Methods

* [**\_\_init\_\_](https://docs.apify.com/api/client/python/api/client/python/reference/class/LoggerOnce.md#__init__)
* [**log](https://docs.apify.com/api/client/python/api/client/python/reference/class/LoggerOnce.md#log)

## Methods<!-- -->[**](#Methods)

### [**](#__init__)\_\_init\_\_

* ****\_\_init\_\_**(logger): None

- #### Parameters

  * ##### logger: logging.Logger

  #### Returns None

### [**](#log)log

* ****log**(message, \*, key, level): None

- Log `message` at `level` the first time `key` is seen on this instance; later calls are no-ops.

  ***

  #### Parameters

  * ##### message: str

    The message to log.

  * ##### keyword-onlykey: str

    Deduplication key. Two calls with the same key emit at most once.

  * ##### optionalkeyword-onlylevel: int = <!-- -->logging.INFO

    Standard `logging` level (e.g. `logging.WARNING`). Defaults to `logging.INFO`.

  #### Returns None
