colosseum.utils.acme.in_memory_logger

 1from typing import Sequence
 2
 3from colosseum.utils.acme.base_logger import Logger, LoggingData
 4
 5
 6class InMemoryLogger(Logger):
 7    """A simple logger that keeps all data in memory."""
 8
 9    def __init__(self):
10        self.reset()
11
12    def write(self, data: LoggingData):
13        self._data.append(data)
14
15    def close(self):
16        pass
17
18    def reset(self) -> None:
19        self._data = []
20
21    @property
22    def data(self) -> Sequence[LoggingData]:
23        return self._data
class InMemoryLogger(colosseum.utils.acme.base_logger.Logger):
 7class InMemoryLogger(Logger):
 8    """A simple logger that keeps all data in memory."""
 9
10    def __init__(self):
11        self.reset()
12
13    def write(self, data: LoggingData):
14        self._data.append(data)
15
16    def close(self):
17        pass
18
19    def reset(self) -> None:
20        self._data = []
21
22    @property
23    def data(self) -> Sequence[LoggingData]:
24        return self._data

A simple logger that keeps all data in memory.

InMemoryLogger()
10    def __init__(self):
11        self.reset()
def write(self, data: Mapping[str, Any]):
13    def write(self, data: LoggingData):
14        self._data.append(data)

Writes data to destination (file, terminal, database, etc).

def close(self):
16    def close(self):
17        pass

Closes the logger, not expecting any further write.

def reset(self) -> None:
19    def reset(self) -> None:
20        self._data = []

Empties the logger.