mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 07:18:27 +01:00
logging: do not disable other loggers (#8995)
Closes https://github.com/iterative/dvc/issues/8631
This commit is contained in:
+1
-2
@@ -153,7 +153,7 @@ def main(argv=None): # noqa: C901
|
||||
from dvc._debug import debugtools
|
||||
from dvc.config import ConfigError
|
||||
from dvc.exceptions import DvcException, NotDvcRepoError
|
||||
from dvc.logger import disable_other_loggers, set_loggers_level
|
||||
from dvc.logger import set_loggers_level
|
||||
|
||||
# NOTE: stderr/stdout may be closed if we are running from dvc.daemon.
|
||||
# On Linux we directly call cli.main after double forking and closing
|
||||
@@ -166,7 +166,6 @@ def main(argv=None): # noqa: C901
|
||||
logging.disable(logging.INFO)
|
||||
|
||||
args = None
|
||||
disable_other_loggers()
|
||||
|
||||
outerLogLevel = logger.level
|
||||
try:
|
||||
|
||||
@@ -180,14 +180,6 @@ def _iter_causes(exc):
|
||||
exc = exc.__cause__
|
||||
|
||||
|
||||
def disable_other_loggers():
|
||||
logging.captureWarnings(True)
|
||||
loggerDict = logging.root.manager.loggerDict # pylint: disable=no-member
|
||||
for logger_name, logger in loggerDict.items():
|
||||
if logger_name != "dvc" and not logger_name.startswith("dvc."):
|
||||
logger.disabled = True # type: ignore[union-attr]
|
||||
|
||||
|
||||
def set_loggers_level(level: int = logging.INFO) -> None:
|
||||
for name in ["dvc", "dvc_objects", "dvc_data"]:
|
||||
logging.getLogger(name).setLevel(level)
|
||||
|
||||
@@ -716,13 +716,10 @@ class BaseExecutor(ABC):
|
||||
|
||||
@staticmethod
|
||||
def _set_log_level(level):
|
||||
from dvc.logger import disable_other_loggers
|
||||
|
||||
# When executor.reproduce is run in a multiprocessing child process,
|
||||
# dvc.cli.main will not be called for that child process so we need to
|
||||
# setup logging ourselves
|
||||
dvc_logger = logging.getLogger("dvc")
|
||||
disable_other_loggers()
|
||||
if level is not None:
|
||||
dvc_logger.setLevel(level)
|
||||
|
||||
|
||||
@@ -49,8 +49,6 @@ import pathlib
|
||||
|
||||
import pytest
|
||||
|
||||
from dvc.logger import disable_other_loggers
|
||||
|
||||
__all__ = [
|
||||
"run_copy",
|
||||
"run_head",
|
||||
@@ -60,9 +58,6 @@ __all__ = [
|
||||
"git_downstream",
|
||||
]
|
||||
|
||||
# see https://github.com/iterative/dvc/issues/3167
|
||||
disable_other_loggers()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def run_copy(tmp_dir, copy_script, dvc):
|
||||
|
||||
Reference in New Issue
Block a user