Skip to content

Commit

Permalink
Add codes to all log events (re-work of PR #4268) (#4319)
Browse files Browse the repository at this point in the history
* re-work of old branch
  • Loading branch information
iknox-fa authored Nov 22, 2021
1 parent f80c78e commit e1a2e8d
Show file tree
Hide file tree
Showing 5 changed files with 378 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Allow `--defer` flag to `dbt snapshot` ([#4110](https://github.com/dbt-labs/dbt-core/issues/4110), [#4296](https://github.com/dbt-labs/dbt-core/pull/4296))
- Install prerelease packages when `version` explicitly references a prerelease version, regardless of `install-prerelease` status ([#4243](https://github.com/dbt-labs/dbt-core/issues/4243), [#4295](https://github.com/dbt-labs/dbt-core/pull/4295))
- Add data attributes to json log messages[#4301](https://github.com/dbt-labs/dbt-core/pull/4301)
- Add event codes to all log events([#4319](https://github.com/dbt-labs/dbt-core/pull/4319))

### Fixes
- Fix serialization error with missing quotes in metrics model ref ([#4252](https://github.com/dbt-labs/dbt-core/issues/4252), [#4287](https://github.com/dbt-labs/dbt-core/pull/4289))
Expand Down
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
@staticmethod
def code() -> 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

0 comments on commit e1a2e8d

Please sign in to comment.