Przeglądaj źródła

set log level in executables, not in some random module

Malte Kraus 8 lat temu
rodzic
commit
19c1134766
4 zmienionych plików z 8 dodań i 1 usunięć
  1. 3 0
      miner.py
  2. 0 1
      src/protocol.py
  3. 2 0
      tests/utils.py
  4. 3 0
      wallet.py

+ 3 - 0
miner.py

@@ -8,6 +8,9 @@ import argparse
 import json
 from urllib.parse import urlparse
 
+import logging
+logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)-8s %(message)s")
+
 import flask
 app = flask.Flask(__name__)
 

+ 0 - 1
src/protocol.py

@@ -20,7 +20,6 @@ HELLO_MSG = b"bl0ckch41n"
 """ The hello message two peers use to make sure they are speaking the same protocol. """
 
 # TODO: set this centrally
-logging.basicConfig(level=logging.INFO)
 socket.setdefaulttimeout(30)
 
 class PeerConnection:

+ 2 - 0
tests/utils.py

@@ -8,6 +8,8 @@ from src.blockchain import *
 from src.crypto import *
 from src.transaction import *
 
+import logging
+logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)-8s %(message)s")
 
 def extend_blockchain(chain, trans:list=None, verify_res=True):
     ts = datetime.utcfromtimestamp(len(chain.blocks))

+ 3 - 0
wallet.py

@@ -13,6 +13,9 @@ import sys
 import json
 from binascii import hexlify
 
+import logging
+logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)-8s %(message)s")
+
 from src.blockchain import Blockchain
 from src.block import Block
 from src.transaction import Transaction, TransactionTarget, TransactionInput