Skip to content

Commit

Permalink
added --noisy option to enable extra logging
Browse files Browse the repository at this point in the history
  • Loading branch information
F483 committed Jan 22, 2016
1 parent 6885f8d commit 954c2ef
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ else
endif
export PYCOIN_NATIVE=openssl
export STORJNODE_QUERY_TIMEOUT=0.3
#export STORJNODE_ENABLE_GLOBAL_LOGGER=1
export STORJNODE_LOGGING_NOISY=1


help:
Expand Down Expand Up @@ -82,7 +82,7 @@ test: setup
$(PEP8) storjnode
$(PEP8) examples
$(PEP8) tests
$(COVERAGE) run --source="storjnode" -m unittest --quiet tests
$(COVERAGE) run --source="storjnode" -m unittest --verbose tests
$(COVERAGE) report --fail-under=85


Expand Down
3 changes: 2 additions & 1 deletion storjnode/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def _reformat_kademlia_node(knode):
class StorjNode(apigen.Definition):
"""Storj protocol reference implementation."""

def __init__(self, wallet=None, quiet=False, debug=False, verbose=False,
def __init__(self, wallet=None,
quiet=False, debug=False, verbose=False, noisy=False,
config=storjnode.common.CONFIG_PATH):
self._init_conifg(config)
self._init_wallet(wallet)
Expand Down
8 changes: 4 additions & 4 deletions storjnode/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from twisted.python import log as _log


ENABLE_GLOBAL_LOGGER = os.environ.get("STORJNODE_ENABLE_GLOBAL_LOGGER")
NOISY = os.environ.get("STORJNODE_LOGGING_NOISY") or "--noisy" in sys.argv


FORMAT = "%(asctime)s %(levelname)s %(name)s %(lineno)d: %(message)s"
Expand All @@ -15,12 +15,12 @@


# make twisted use standard library logging module
_observer = _log.PythonLoggingObserver() # pragma: no cover
_observer.start() # pragma: no cover
_observer = _log.PythonLoggingObserver()
_observer.start()


# silence global logger
if ENABLE_GLOBAL_LOGGER:
if NOISY:
_logging.basicConfig(format=FORMAT)
else:
_logging.basicConfig(format=FORMAT, level=LEVEL_QUIET)
Expand Down
6 changes: 3 additions & 3 deletions storjnode/network/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def __init__(self, *args, **kwargs):
self.messages_received = Queue(maxsize=max_messages)
KademliaProtocol.__init__(self, *args, **kwargs)
self.log = storjnode.log.getLogger("kademlia.protocol")
if not storjnode.log.ENABLE_GLOBAL_LOGGER:
self.log.setLevel(60)
self.noisy = False
if not storjnode.log.NOISY:
self.log.setLevel(storjnode.log.LEVEL_QUIET)
self.noisy = storjnode.log.NOISY

def has_messages(self):
return not self.messages_received.empty()
Expand Down
4 changes: 2 additions & 2 deletions storjnode/network/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ def __init__(self, key, port, ksize=20, alpha=3, storage=None,
self.ksize = ksize
self.alpha = alpha
self.log = storjnode.log.getLogger("kademlia.network")
if not storjnode.log.ENABLE_GLOBAL_LOGGER:
self.log.setLevel(60)
if not storjnode.log.NOISY:
self.log.setLevel(storjnode.log.LEVEL_QUIET)

self.storage = storage or ForgetfulStorage()
self.node = KademliaNode(self.get_id())
Expand Down

0 comments on commit 954c2ef

Please sign in to comment.