/usr/lib/python3/dist-packages/provisioningserver/logger/_tftp.py is in python3-maas-provisioningserver 2.4.0~beta2-6865-gec43e47e6-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | # Copyright 2016 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""TFTP-specific logging stuff."""
__all__ = [
'configure_tftp_logging',
]
from provisioningserver.logger._common import LoggingMode
from provisioningserver.logger._twisted import LegacyLogger
from provisioningserver.utils import typed
from twisted.logger import (
globalLogPublisher,
LogLevel,
)
@typed
def configure_tftp_logging(verbosity: int, mode: LoggingMode):
"""Configure logging in `python-tx-tftp`.
This is done by monkey-patching `LegacyLogger`s into three of its modules.
Each of these is connected to a custom observer, `observe_tftp`, that has
an opportunity to filter or modify log events before passing them on to
the global log publisher.
:param verbosity: See `get_logging_level`.
:param mode: The mode in which to configure logging. See `LoggingMode`.
"""
try:
from tftp import bootstrap, protocol, session
except ImportError:
# python-tx-tftp not installed; nothing to be done.
return
for module in (bootstrap, protocol, session):
LegacyLogger.install(module, observer=observe_tftp)
def observe_tftp(event, forwardTo=globalLogPublisher):
if "log_level" in event and event["log_level"] is LogLevel.info:
# Informational messages emitted by `python-tx-tftp` are, in the
# context of MAAS, debug level at most.
event["log_level"] = LogLevel.debug
forwardTo(event)
|