diff --git a/core/dbt/deps/git.py b/core/dbt/deps/git.py index cec6206a4a0..6799de584d8 100644 --- a/core/dbt/deps/git.py +++ b/core/dbt/deps/git.py @@ -94,7 +94,7 @@ def _fetch_metadata(self, project, renderer) -> ProjectPackageMetadata: 'The git package "{}" \n\tis {}.\n\tThis can introduce ' 'breaking changes into your project without warning!\n\nSee {}' .format(self.git, self.unpinned_msg(), PIN_PACKAGE_URL), - log_fmt=ui.yellow('WARNING: {}') + log_fmt=ui.yellow(warning_tag('{}')) ) loaded = Project.from_project_root(path, renderer) return ProjectPackageMetadata.from_project(loaded) diff --git a/core/dbt/events/functions.py b/core/dbt/events/functions.py index 552e2e01cda..77f8f947556 100644 --- a/core/dbt/events/functions.py +++ b/core/dbt/events/functions.py @@ -3,6 +3,7 @@ import dbt.events.functions as this # don't worry I hate it too. from dbt.events.base_types import Cli, Event, File, ShowException import dbt.flags as flags +import dbt.ui as ui # TODO this will need to move eventually from dbt.logger import SECRET_ENV_PREFIX, make_log_dir_if_missing, GLOBAL_LOGGER import io @@ -110,6 +111,19 @@ def scrub_secrets(msg: str, secrets: List[str]) -> str: T_Event = TypeVar('T_Event', bound=Event) +def format_level(level): + fixed_width = level.ljust(5) + # TODO turn off all color everwhere for file + JSON + if not this.format_color: + return fixed_width + elif level == 'warn': + return ui.yellow(fixed_width) + elif level == 'error': + return ui.red(fixed_width) + else: + return fixed_width + + # translates an Event to a completely formatted text-based log line # you have to specify which message you want. (i.e. - e.message, e.cli_msg(), e.file_msg()) # type hinting everything as strings so we don't get any unintentional string conversions via str() @@ -117,7 +131,7 @@ def create_text_log_line(e: T_Event, msg_fn: Callable[[T_Event], str]) -> str: color_tag: str = '' if this.format_color else Style.RESET_ALL ts: str = e.ts.strftime("%H:%M:%S") scrubbed_msg: str = scrub_secrets(msg_fn(e), env_secrets()) - level: str = e.level_tag() + level: str = format_level(e.level_tag()) log_line: str = f"{color_tag}{ts} | [ {level} ] | {scrubbed_msg}" return log_line diff --git a/core/dbt/parser/schemas.py b/core/dbt/parser/schemas.py index b25b050d614..29bfdb2c291 100644 --- a/core/dbt/parser/schemas.py +++ b/core/dbt/parser/schemas.py @@ -961,7 +961,7 @@ def parse_patch( macro = self.manifest.macros.get(unique_id) if not macro: warn_or_error( - f'WARNING: Found patch for macro "{patch.name}" ' + f'Found patch for macro "{patch.name}" ' f'which was not found' ) return diff --git a/core/dbt/ui.py b/core/dbt/ui.py index 6ea57adfd2a..7b527e75bdc 100644 --- a/core/dbt/ui.py +++ b/core/dbt/ui.py @@ -66,4 +66,6 @@ def line_wrap_message( def warning_tag(msg: str) -> str: - return f'[{yellow("WARNING")}]: {msg}' + # duplicative now that new structured logs include levels + # return f'[{yellow("WARNING")}]: {msg}' + return msg