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

repo: get default logger level from logger #1942

Merged
merged 1 commit into from
Apr 30, 2019
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
2 changes: 1 addition & 1 deletion dvc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class Config(object): # pylint: disable=too-many-instance-attributes
SECTION_CORE_STORAGEPATH = "storagepath"

SECTION_CORE_SCHEMA = {
Optional(SECTION_CORE_LOGLEVEL, default="info"): And(
Optional(SECTION_CORE_LOGLEVEL): And(
str, Use(str.lower), SECTION_CORE_LOGLEVEL_SCHEMA
),
Optional(SECTION_CORE_REMOTE, default=""): And(str, Use(str.lower)),
Expand Down
8 changes: 3 additions & 5 deletions dvc/repo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,9 @@ def __init__(self, root_dir=None):

core = self.config.config[Config.SECTION_CORE]

logger.setLevel(
logging.getLevelName(
core.get(Config.SECTION_CORE_LOGLEVEL, "info").upper()
)
)
level = core.get(Config.SECTION_CORE_LOGLEVEL)
if level:
logger.setLevel(level.upper())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea of log level defined in repo config looks a bit ill-defined. What if we have instantiated several Repos? The one instantiated later will just override everything. The order will be meaningful, which feels weird.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that probably should be changed. But do you think it is a scope of current issue? Or should we rather introduce this change and make new task for removing the config from Repo?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Suor , @pared , this could be solved on a separate PR, maybe opening an issue for discussion.
This PR is kind of important, otherwise we would have an unusable --quiet option.


self.cache = Cache(self)
self.cloud = DataCloud(self, config=self.config.config)
Expand Down
7 changes: 7 additions & 0 deletions tests/func/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,10 @@ def test_cli(self):
self.assertEqual(ret, 0)

self._test_init()


def test_init_quiet_should_not_display_welcome_screen(git, caplog):
ret = main(["init", "--quiet"])

assert 0 == ret
assert "" == caplog.text