Skip to content
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
Next Next commit
update config use structured logging
  • Loading branch information
emmyoop committed Nov 2, 2021
commit 4c12e9bf560cba5ee04138dc5580a48766fae1f8
8 changes: 3 additions & 5 deletions core/dbt/config/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
from dbt.exceptions import ValidationException
from dbt.exceptions import RuntimeException
from dbt.exceptions import validator_error_message
from dbt.logger import GLOBAL_LOGGER as logger
from dbt.events.types import MissingProfileTarget
from dbt.events.functions import fire_event
from dbt.utils import coerce_dict_str

from .renderer import ProfileRenderer
Expand Down Expand Up @@ -291,10 +292,7 @@ def render_profile(
target_name = renderer.render_value(raw_profile['target'])
else:
target_name = 'default'
logger.debug(
"target not specified in profile '{}', using '{}'"
.format(profile_name, target_name)
)
fire_event(MissingProfileTarget(profile_name, target_name))

raw_profile_data = cls._get_profile_data(
raw_profile, profile_name, target_name
Expand Down
12 changes: 4 additions & 8 deletions core/dbt/config/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
from dbt.contracts.connection import AdapterRequiredConfig, Credentials
from dbt.contracts.graph.manifest import ManifestMetadata
from dbt.contracts.relation import ComponentName
from dbt.logger import GLOBAL_LOGGER as logger
from dbt.events.types import ProfileLoadError, ProfileNotFound
from dbt.events.functions import fire_event
from dbt.ui import warning_tag

from dbt.contracts.project import Configuration, UserConfig
Expand Down Expand Up @@ -534,13 +535,8 @@ def _get_rendered_profile(
args, profile_renderer, profile_name
)
except (DbtProjectError, DbtProfileError) as exc:
logger.debug(
'Profile not loaded due to error: {}', exc, exc_info=True
)
logger.info(
'No profile "{}" found, continuing with no target',
profile_name
)
fire_event(ProfileLoadError(exc, exc_info=True))
fire_event(ProfileNotFound(profile_name))
# return the poisoned form
profile = UnsetProfile()
# disable anonymous usage statistics
Expand Down
8 changes: 4 additions & 4 deletions core/dbt/config/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from typing import Dict, Any

from dbt.clients import yaml_helper
from dbt.events.functions import fire_event
from dbt.exceptions import raise_compiler_error, ValidationException
from dbt.logger import GLOBAL_LOGGER as logger
from dbt.events.types import InvalidVarsYAML
from dbt.events.functions import fire_event


def parse_cli_vars(var_string: str) -> Dict[str, Any]:
Expand All @@ -17,7 +19,5 @@ def parse_cli_vars(var_string: str) -> Dict[str, Any]:
"The --vars argument must be a YAML dictionary, but was "
"of type '{}'".format(type_name))
except ValidationException:
logger.error(
"The YAML provided in the --vars argument is not valid.\n"
)
fire_event(InvalidVarsYAML())
raise
31 changes: 31 additions & 0 deletions core/dbt/events/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,33 @@ class MacroEventDebug(DebugLevel, CliEventABC):

def cli_msg(self) -> str:
return self.msg
class MissingProfileTarget(InfoLevel, CliEventABC):
profile_name: str
target_name: str

def cli_msg(self) -> str:
return f"target not specified in profile '{self.profile_name}', using '{self.target_name}'"


@dataclass
class ProfileLoadError(DebugLevel, CliEventABC):
profile_name: str

def cli_msg(self) -> str:
return f"Profile not loaded due to error: {}", exc, exc_info=True


@dataclass
class ProfileNotFound(InfoLevel, CliEventABC):
profile_name: str

def cli_msg(self) -> str:
return f'No profile "{self.profile_name}" found, continuing with no target'


class InvalidVarsYAML(ErrorLevel, CliEventABC):
def cli_msg(self) -> str:
return "The YAML provided in the --vars argument is not valid.\n"


@dataclass
Expand Down Expand Up @@ -364,3 +391,7 @@ def cli_msg(self) -> str:
NewConnectionOpening(connection_state='')
TimingInfoCollected()
MergedFromState(nbr_merged=0, sample=[])
MissingProfileTarget(profile_name='', target_name='')
ProfileLoadError()
ProfileNotFound(profile_name='')
InvalidVarsYAML()