Skip to content

Commit

Permalink
[CT-679] flip logic around reset color detection (#5394)
Browse files Browse the repository at this point in the history
  • Loading branch information
darin-reify authored Jun 29, 2022
1 parent d5608dc commit d63ad4c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .changes/unreleased/Fixes-20220617-160027.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Fixes
body: fixes handling of RESET color code with USE_COLORS=False
time: 2022-06-17T16:00:27.038058-04:00
custom:
Author: darin-reify
Issue: "5288"
PR: "5394"
8 changes: 6 additions & 2 deletions core/dbt/events/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,12 @@ def event_to_serializable_dict(

# translates an Event to a completely formatted text-based log line
# type hinting everything as strings so we don't get any unintentional string conversions via str()
def reset_color() -> str:
return "" if not this.format_color else Style.RESET_ALL


def create_info_text_log_line(e: T_Event) -> str:
color_tag: str = "" if this.format_color else Style.RESET_ALL
color_tag: str = reset_color()
ts: str = get_ts().strftime("%H:%M:%S")
scrubbed_msg: str = scrub_secrets(e.message(), env_secrets())
log_line: str = f"{color_tag}{ts} {scrubbed_msg}"
Expand All @@ -180,7 +184,7 @@ def create_debug_text_log_line(e: T_Event) -> str:
if type(e) == MainReportVersion:
separator = 30 * "="
log_line = f"\n\n{separator} {get_ts()} | {get_invocation_id()} {separator}\n"
color_tag: str = "" if this.format_color else Style.RESET_ALL
color_tag: str = reset_color()
ts: str = get_ts().strftime("%H:%M:%S.%f")
scrubbed_msg: str = scrub_secrets(e.message(), env_secrets())
level: str = e.level_tag() if len(e.level_tag()) == 5 else f"{e.level_tag()} "
Expand Down

0 comments on commit d63ad4c

Please sign in to comment.