colosseum.utils.acme.base_logger
1import abc 2from typing import Any, Mapping, Sequence 3 4LoggingData = Mapping[str, Any] 5 6 7class Logger(abc.ABC): 8 """A logger has a `write` method.""" 9 10 @property 11 @abc.abstractmethod 12 def data(self) -> Sequence[LoggingData]: 13 pass 14 15 @abc.abstractmethod 16 def write(self, data: LoggingData) -> None: 17 """Writes `data` to destination (file, terminal, database, etc).""" 18 19 @abc.abstractmethod 20 def close(self) -> None: 21 """Closes the logger, not expecting any further write.""" 22 23 @abc.abstractmethod 24 def reset(self) -> None: 25 """Empties the logger.""" 26 27 28class NoOpLogger(Logger): 29 """Simple Logger which does nothing and outputs no logs. 30 31 This should be used sparingly, but it can prove useful if we want to quiet an 32 individual component and have it produce no logging whatsoever. 33 """ 34 35 @property 36 def data(self) -> Sequence[LoggingData]: 37 raise NotImplementedError() 38 39 def write(self, data: LoggingData): 40 pass 41 42 def close(self): 43 pass
class
Logger(abc.ABC):
8class Logger(abc.ABC): 9 """A logger has a `write` method.""" 10 11 @property 12 @abc.abstractmethod 13 def data(self) -> Sequence[LoggingData]: 14 pass 15 16 @abc.abstractmethod 17 def write(self, data: LoggingData) -> None: 18 """Writes `data` to destination (file, terminal, database, etc).""" 19 20 @abc.abstractmethod 21 def close(self) -> None: 22 """Closes the logger, not expecting any further write.""" 23 24 @abc.abstractmethod 25 def reset(self) -> None: 26 """Empties the logger."""
A logger has a write
method.
@abc.abstractmethod
def
write(self, data: Mapping[str, Any]) -> None:
16 @abc.abstractmethod 17 def write(self, data: LoggingData) -> None: 18 """Writes `data` to destination (file, terminal, database, etc)."""
Writes data
to destination (file, terminal, database, etc).
29class NoOpLogger(Logger): 30 """Simple Logger which does nothing and outputs no logs. 31 32 This should be used sparingly, but it can prove useful if we want to quiet an 33 individual component and have it produce no logging whatsoever. 34 """ 35 36 @property 37 def data(self) -> Sequence[LoggingData]: 38 raise NotImplementedError() 39 40 def write(self, data: LoggingData): 41 pass 42 43 def close(self): 44 pass
Simple Logger which does nothing and outputs no logs.
This should be used sparingly, but it can prove useful if we want to quiet an individual component and have it produce no logging whatsoever.