| 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): |
| 12 | # type: (Optional[Callable[[str], None]]) -> None |
| 13 | self._logging_function = log # type: Optional[Callable[[str], None]] |
| 14 | |
| 15 | def _log(self, msg): |
| 16 | # type: (str) -> None |
| 17 | if self._logging_function: |
| 18 | self._logging_function(msg) |
| 19 | |
| 20 | @property |
| 21 | def logger(self): |
| 22 | # type: () -> Optional[Callable[[str], None]] |
| 23 | return self._logging_function |