| 1 | #!/usr/bin/env python3 |
| 2 | # |
| 3 | # Copyright (C) 2022 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
| 4 | # |
| 5 | # SPDX-License-Identifier: GPL-2.0-only |
| 6 | |
| 7 | from typing import Callable, Optional |
| 8 | |
| 9 | |
| 10 | class _Logger: |
| 11 | def __init__(self, log: Optional[Callable[[str], None]]): |
| 12 | self._logging_function: Optional[Callable[[str], None]] = log |
| 13 | |
| 14 | def _log(self, msg: str) -> None: |
| 15 | if self._logging_function: |
| 16 | self._logging_function(msg) |
| 17 | |
| 18 | @property |
| 19 | def logger(self) -> Optional[Callable[[str], None]]: |
| 20 | return self._logging_function |