diff options
author | 2022-11-05 13:39:52 +0000 | |
---|---|---|
committer | 2022-11-05 14:05:00 +0000 | |
commit | 962968fecedca3bef33ba9524d87ffedf815f16d (patch) | |
tree | 3dd7b6c6cae4f01c8a5aae3e2371bd3a5e9dd0e7 /botcore/utils/logging.py | |
parent | Update pyproject.toml module meta data (diff) |
Rename package due to naming conflict
Diffstat (limited to 'botcore/utils/logging.py')
-rw-r--r-- | botcore/utils/logging.py | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/botcore/utils/logging.py b/botcore/utils/logging.py deleted file mode 100644 index 1f1c8bac..00000000 --- a/botcore/utils/logging.py +++ /dev/null @@ -1,51 +0,0 @@ -"""Common logging related functions.""" - -import logging -import typing - -if typing.TYPE_CHECKING: - LoggerClass = logging.Logger -else: - LoggerClass = logging.getLoggerClass() - -TRACE_LEVEL = 5 - - -class CustomLogger(LoggerClass): - """Custom implementation of the :obj:`logging.Logger` class with an added :obj:`trace` method.""" - - def trace(self, msg: str, *args, **kwargs) -> None: - """ - Log the given message with the severity ``"TRACE"``. - - To pass exception information, use the keyword argument exc_info with a true value: - - .. code-block:: py - - logger.trace("Houston, we have an %s", "interesting problem", exc_info=1) - - Args: - msg: The message to be logged. - args, kwargs: Passed to the base log function as is. - """ - if self.isEnabledFor(TRACE_LEVEL): - self.log(TRACE_LEVEL, msg, *args, **kwargs) - - -def get_logger(name: typing.Optional[str] = None) -> CustomLogger: - """ - Utility to make mypy recognise that logger is of type :obj:`CustomLogger`. - - Args: - name: The name given to the logger. - - Returns: - An instance of the :obj:`CustomLogger` class. - """ - return typing.cast(CustomLogger, logging.getLogger(name)) - - -# Setup trace level logging so that we can use it within botcore. -logging.TRACE = TRACE_LEVEL -logging.setLoggerClass(CustomLogger) -logging.addLevelName(TRACE_LEVEL, "TRACE") |