make it easier to configure logging for electrumx (#514)

* make it easier to configure logging for electrumx
This commit is contained in:
Lex Berezhny 2018-07-09 23:17:42 -04:00 committed by Neil
parent ddae0079a7
commit 45111898b3
8 changed files with 16 additions and 8 deletions

View File

@ -19,7 +19,8 @@ class EnvBase(object):
pass
def __init__(self):
self.logger = logging.getLogger(self.__class__.__name__)
self.logger = logging.getLogger(__name__)\
.getChild(self.__class__.__name__)
self.allow_root = self.boolean('ALLOW_ROOT', False)
self.host = self.default('HOST', 'localhost')
self.rpc_host = self.default('RPC_HOST', 'localhost')

View File

@ -36,7 +36,8 @@ class ServerBase(object):
'''Save the environment, perform basic sanity checks, and set the
event loop policy.
'''
self.logger = logging.getLogger(self.__class__.__name__)
self.logger = logging.getLogger(__name__)\
.getChild(self.__class__.__name__)
self.env = env
# Sanity checks

View File

@ -26,7 +26,8 @@ class Prefetcher(object):
'''Prefetches blocks (in the forward direction only).'''
def __init__(self, bp):
self.logger = logging.getLogger(self.__class__.__name__)
self.logger = logging.getLogger(__name__)\
.getChild(self.__class__.__name__)
self.bp = bp
self.caught_up = False
# Access to fetched_height should be protected by the semaphore

View File

@ -37,7 +37,8 @@ class Daemon(object):
'''Raised when the daemon returns an error in its results.'''
def __init__(self, env):
self.logger = logging.getLogger(self.__class__.__name__)
self.logger = logging.getLogger(__name__)\
.getChild(self.__class__.__name__)
self.coin = env.coin
self.set_urls(env.coin.daemon_urls(env.daemon_url))
self._height = None

View File

@ -42,7 +42,8 @@ class DB(object):
'''Raised on general DB errors generally indicating corruption.'''
def __init__(self, env):
self.logger = logging.getLogger(self.__class__.__name__)
self.logger = logging.getLogger(__name__)\
.getChild(self.__class__.__name__)
self.env = env
self.coin = env.coin

View File

@ -25,7 +25,8 @@ class History(object):
DB_VERSIONS = [0]
def __init__(self):
self.logger = logging.getLogger(self.__class__.__name__)
self.logger = logging.getLogger(__name__)\
.getChild(self.__class__.__name__)
# For history compaction
self.max_hist_row_entries = 12500
self.unflushed = defaultdict(partial(array.array, 'I'))

View File

@ -33,7 +33,8 @@ class MemPool(object):
'''
def __init__(self, bp, controller):
self.logger = logging.getLogger(self.__class__.__name__)
self.logger = logging.getLogger(__name__)\
.getChild(self.__class__.__name__)
self.daemon = bp.daemon
self.controller = controller
self.coin = bp.coin

View File

@ -224,7 +224,8 @@ class PeerManager(object):
Issues a 'peers.subscribe' RPC to them and tells them our data.
'''
def __init__(self, env, controller):
self.logger = logging.getLogger(self.__class__.__name__)
self.logger = logging.getLogger(__name__)\
.getChild(self.__class__.__name__)
# Initialise the Peer class
Peer.DEFAULT_PORTS = env.coin.PEER_DEFAULT_PORTS
self.env = env