Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add codes to all log events (re-work of PR #4268) #4319

Merged
merged 2 commits into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion core/dbt/clients/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ def run_cmd(
fire_event(SystemStdErrMsg(bmsg=err))

if proc.returncode != 0:
fire_event(SystemReportReturnCode(code=proc.returncode))
fire_event(SystemReportReturnCode(returncode=proc.returncode))
raise dbt.exceptions.CommandResultError(cwd, cmd, proc.returncode,
out, err)

Expand Down
9 changes: 8 additions & 1 deletion core/dbt/events/base_types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from abc import ABCMeta, abstractmethod
from abc import ABCMeta, abstractmethod, abstractproperty
from dataclasses import dataclass
from datetime import datetime
import os
Expand Down Expand Up @@ -58,6 +58,13 @@ class Event(metaclass=ABCMeta):
ts: Optional[datetime] = None # use getter for non-optional
pid: Optional[int] = None # use getter for non-optional

# four digit string code that uniquely identifies this type of event
# uniqueness and valid characters are enforced by tests
@abstractproperty
@classmethod
def code(cls) -> str:
raise Exception("code() not implemented for event")

# do not define this yourself. inherit it from one of the above level types.
@abstractmethod
def level_tag(self) -> str:
Expand Down
5 changes: 5 additions & 0 deletions core/dbt/events/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
@dataclass
class IntegrationTestInfo(InfoLevel, Cli):
msg: str
code: str = "T001"

def message(self) -> str:
return f"Integration Test: {self.msg}"
Expand All @@ -23,6 +24,7 @@ def message(self) -> str:
@dataclass
class IntegrationTestDebug(DebugLevel, Cli):
msg: str
code: str = "T002"

def message(self) -> str:
return f"Integration Test: {self.msg}"
Expand All @@ -31,6 +33,7 @@ def message(self) -> str:
@dataclass
class IntegrationTestWarn(WarnLevel, Cli):
msg: str
code: str = "T003"

def message(self) -> str:
return f"Integration Test: {self.msg}"
Expand All @@ -39,6 +42,7 @@ def message(self) -> str:
@dataclass
class IntegrationTestError(ErrorLevel, Cli):
msg: str
code: str = "T004"

def message(self) -> str:
return f"Integration Test: {self.msg}"
Expand All @@ -47,6 +51,7 @@ def message(self) -> str:
@dataclass
class IntegrationTestException(ShowException, ErrorLevel, Cli):
msg: str
code: str = "T005"

def message(self) -> str:
return f"Integration Test: {self.msg}"
Expand Down
Loading