Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions dftimewolf/cli/dftimewolf_recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import sys
import typing
import uuid
from typing import Any, Optional, cast
from typing import Any, Optional

from dftimewolf import config
from dftimewolf.lib import errors
Expand Down Expand Up @@ -64,7 +64,7 @@
}


logger = cast(logging_utils.WolfLogger, logging.getLogger('dftimewolf'))
logger = logging.getLogger('dftimewolf')


class DFTimewolfTool(object):
Expand All @@ -87,7 +87,7 @@ def __init__(
self._recipes_manager = recipes_manager.RecipesManager()
self._recipe: resources.Recipe
self._uuid = workflow_uuid or str(uuid.uuid4())
logger.success(f'dfTimewolf tool initialized with UUID: {self._uuid}')
logger.info(f'dfTimewolf tool initialized with UUID: {self._uuid}')

self._DetermineDataFilesPath()
self.LoadConfiguration(config_path)
Expand Down Expand Up @@ -394,9 +394,6 @@ def SetupLogging(stdout_log: bool = False) -> None:
Args:
stdout_log (bool): Whether to log to stdout as well as a file.
"""
# Add a custom level name
logging.addLevelName(logging_utils.SUCCESS, 'SUCCESS')

# Clear handlers (for dependencies that are setting them)
root_log = logging.getLogger()
root_log.handlers = []
Expand Down
15 changes: 0 additions & 15 deletions dftimewolf/lib/logging_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,8 @@ def GenerateTempLogFile() -> str:
logfile.close()
return log_filename


SUCCESS = 25 # 25 is right between INFO and WARNING


LEVEL_COLOR_MAP = {
'WARNING': '\u001b[0;93m',
'SUCCESS': '\u001b[1;30;42m',
'INFO': '\u001b[0;97m',
'DEBUG': '\u001b[0;94m',
'CRITICAL': '\u001b[1;31;107m',
Expand All @@ -40,16 +35,6 @@ def GenerateTempLogFile() -> str:
_DEFAULT_FORMATTER = logging.Formatter('[%(asctime)sZ] [%(name)-20s] %(levelname)-8s %(message)s')


class WolfLogger(logging.Logger):
"""Custom logging Class with a `success` logging function."""

def success(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=invalid-name
"""Logs a success message."""
super(WolfLogger, self).log(SUCCESS, *args, **kwargs)

logging.setLoggerClass(WolfLogger)


class WolfFormatter(logging.Formatter):
"""Helper class used to add color to log messages depending on their level."""

Expand Down
8 changes: 3 additions & 5 deletions dftimewolf/lib/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
import logging
import sys
import traceback
from typing import Any, Callable, Literal, NoReturn, Optional, overload, Sequence, Type, TypeVar, cast
from typing import Any, Callable, Literal, NoReturn, Optional, overload, Sequence, Type, TypeVar

from dftimewolf.lib import cache
from dftimewolf.lib import errors
from dftimewolf.lib import logging_utils
from dftimewolf.lib import spanner_telemetry as telemetry
from dftimewolf.lib import opentelemetry
from dftimewolf.lib.containers import interface
Expand Down Expand Up @@ -54,8 +53,7 @@ def __init__(self,
self._telemetry = telemetry_
self._publish_message_callback = publish_message_callback

self.logger = cast(logging_utils.WolfLogger,
logging.getLogger(name=self.name))
self.logger = logging.getLogger(name=self.name)
self.logger.parent = logging.getLogger('dftimewolf')

def LogTelemetry(self, data: dict[str, str]) -> None:
Expand Down Expand Up @@ -141,7 +139,7 @@ def PublishMessage(
elif is_error:
self.logger.error(message)
else:
self.logger.success(message)
self.logger.info(message)
self._publish_message_callback(self.name, message, is_error)

def RegisterStreamingCallback(
Expand Down
Loading