Skip to content

Commit

Permalink
Move logger to separate file (#60)
Browse files Browse the repository at this point in the history
* Move logger to separate file

* Move logger to separate file
  • Loading branch information
ismailsimsek authored Mar 2, 2025
1 parent 1a5dc62 commit f564ab5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
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

0 comments on commit f564ab5

Please sign in to comment.