Skip to content

test: Use INFO as default log level to reduce amount of logs #814

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

Merged
merged 1 commit into from
Oct 18, 2023
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
11 changes: 11 additions & 0 deletions hathor/cli/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ def setup_logging(
else:
handlers = ['pretty']

# Flag to enable debug level for both sync-v1 and sync-v2.
debug_sync = False and debug

# See: https://docs.python.org/3/library/logging.config.html#configuration-dictionary-schema
logging.config.dictConfig({
'version': 1,
Expand Down Expand Up @@ -207,6 +210,14 @@ def setup_logging(
'handlers': handlers,
'level': 'DEBUG' if debug else 'INFO',
},
'hathor.p2p.sync_v1': {
'handlers': handlers,
'level': 'DEBUG' if debug_sync else 'INFO',
},
'hathor.p2p.sync_v2': {
'handlers': handlers,
'level': 'DEBUG' if debug_sync else 'INFO',
}
}
})

Expand Down
4 changes: 3 additions & 1 deletion tests/unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from twisted.trial import unittest

from hathor.builder import BuildArtifacts, Builder
from hathor.cli.util import setup_logging
from hathor.conf import HathorSettings
from hathor.conf.get_settings import get_settings
from hathor.daa import TestMode, _set_test_mode
Expand Down Expand Up @@ -104,14 +105,15 @@ class TestCase(unittest.TestCase):
seed_config: Optional[int] = None

def setUp(self):
setup_logging()
_set_test_mode(TestMode.TEST_ALL_WEIGHT)
self.tmpdirs = []
self.clock = TestMemoryReactorClock()
self.clock.advance(time.time())
self.log = logger.new()
self.reset_peer_id_pool()
self.seed = secrets.randbits(64) if self.seed_config is None else self.seed_config
self.log.debug('set seed', seed=self.seed)
self.log.info('set seed', seed=self.seed)
self.rng = Random(self.seed)
self._pending_cleanups = []
self._settings = get_settings()
Expand Down