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

Move logger to separate file #60

Merged
merged 2 commits into from
Mar 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 1 addition & 17 deletions opendbt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from opendbt.dbt import patch_dbt

patch_dbt()
from opendbt.logger import OpenDbtLogger
from opendbt.utils import Utils
######################

Expand All @@ -18,23 +19,6 @@
from dbt.exceptions import DbtRuntimeError
from dbt.task.base import get_nearest_project_dir


class OpenDbtLogger:
_log = None

@property
def log(self) -> logging.Logger:
if self._log is None:
self._log = logging.getLogger(name="opendbt")
if not self._log.hasHandlers():
handler = logging.StreamHandler(sys.stdout)
formatter = logging.Formatter("[%(asctime)s] {%(filename)s:%(lineno)d} %(levelname)s - %(message)s")
handler.setFormatter(formatter)
handler.setLevel(logging.INFO)
self._log.addHandler(handler)
return self._log


class OpenDbtCli:

def __init__(self, project_dir: Path, profiles_dir: Path = None, callbacks: list = None):
Expand Down
18 changes: 18 additions & 0 deletions opendbt/logger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import logging
import sys


class OpenDbtLogger:
_log = None

@property
def log(self) -> logging.Logger:
if self._log is None:
self._log = logging.getLogger(name="opendbt")
if not self._log.hasHandlers():
handler = logging.StreamHandler(sys.stdout)
formatter = logging.Formatter("[%(asctime)s] {%(filename)s:%(lineno)d} %(levelname)s - %(message)s")
handler.setFormatter(formatter)
handler.setLevel(logging.INFO)
self._log.addHandler(handler)
return self._log
Loading