Skip to content

Commit

Permalink
Fix log-level option
Browse files Browse the repository at this point in the history
  • Loading branch information
ltm committed Oct 29, 2020
1 parent 5364b86 commit 4db37d7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 2 additions & 3 deletions icloudpd/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import sys
import logging
from logging import DEBUG, INFO
from logging import INFO


class IPDLogger(logging.Logger):
Expand Down Expand Up @@ -32,11 +32,10 @@ def tqdm_write(self, message, loglevel=INFO):
self.tqdm.write(message)


def setup_logger(loglevel=DEBUG):
def setup_logger():
"""Set up logger and add stdout handler"""
logging.setLoggerClass(IPDLogger)
logger = logging.getLogger("icloudpd")
logger.setLevel(loglevel)
has_stdout_handler = False
for handler in logger.handlers:
if handler.name == "stdoutLogger":
Expand Down
10 changes: 10 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
import os
import shutil
from vcr import VCR
import pytest
from click.testing import CliRunner
from icloudpd.base import main

vcr = VCR(decode_compressed_response=True)


class CliTestCase(TestCase):
@pytest.fixture(autouse=True)
def inject_fixtures(self, caplog):
self._caplog = caplog

def test_cli(self):
runner = CliRunner()
result = runner.invoke(main, ["--help"])
Expand Down Expand Up @@ -37,8 +42,11 @@ def test_log_levels(self):
"tests/fixtures/Photos",
],
)
self.assertNotIn("DEBUG", self._caplog.text)
self.assertIn("INFO", self._caplog.text)
assert result.exit_code == 0
with vcr.use_cassette("tests/vcr_cassettes/listing_photos.yml"):
self._caplog.clear()
result = runner.invoke(
main,
[
Expand All @@ -54,6 +62,8 @@ def test_log_levels(self):
"tests/fixtures/Photos",
],
)
self.assertNotIn("DEBUG", self._caplog.text)
self.assertNotIn("INFO", self._caplog.text)
assert result.exit_code == 0

def test_tqdm(self):
Expand Down

0 comments on commit 4db37d7

Please sign in to comment.