Skip to content

Commit

Permalink
dont disable existing loggers when dvc is set up (#3345)
Browse files Browse the repository at this point in the history
* dont disable existing loggers when dvc is set up

* corrected code style

* dont disable existing loggers, fixes

Co-authored-by: Guro Bokum <JIoJIaJIu@gmail.com>
  • Loading branch information
ttekampe and gurobokum authored Feb 27, 2020
1 parent d8778e7 commit de453ab
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
24 changes: 8 additions & 16 deletions dvc/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ def _stack_trace(exc_info):
)


def disable_other_loggers():
root = logging.root
for (logger_name, logger) in root.manager.loggerDict.items():
if logger_name != "dvc" and not logger_name.startswith("dvc."):
logger.disabled = True


def setup(level=logging.INFO):
colorama.init()

Expand Down Expand Up @@ -183,22 +190,7 @@ def setup(level=logging.INFO):
"console_errors",
],
},
"paramiko": {
"level": logging.CRITICAL,
"handlers": [
"console_info",
"console_debug",
"console_errors",
],
},
"flufl.lock": {
"level": logging.CRITICAL,
"handlers": [
"console_info",
"console_debug",
"console_errors",
],
},
},
"disable_existing_loggers": False,
}
)
3 changes: 2 additions & 1 deletion dvc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from dvc.exceptions import DvcParserError
from dvc.exceptions import NotDvcRepoError
from dvc.external_repo import clean_repos
from dvc.logger import FOOTER
from dvc.logger import disable_other_loggers, FOOTER
from dvc.utils import format_link
from dvc.remote.pool import close_pools

Expand All @@ -34,6 +34,7 @@ def main(argv=None):
"""
args = None
cmd = None
disable_other_loggers()

outerLogLevel = logger.level
try:
Expand Down
5 changes: 2 additions & 3 deletions tests/dir_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@

import os
import pathlib
import logging
from contextlib import contextmanager

import pytest
from funcy import lmap, retry

from dvc.logger import disable_other_loggers
from dvc.utils.fs import makedirs
from dvc.compat import fspath, fspath_py35

Expand All @@ -67,8 +67,7 @@


# see https://github.com/iterative/dvc/issues/3167
git_logger = logging.getLogger("git")
git_logger.setLevel(logging.CRITICAL)
disable_other_loggers()


class TmpDir(pathlib.Path):
Expand Down

0 comments on commit de453ab

Please sign in to comment.