forked from LBRYCommunity/lbry-sdk
Add TRACE level logging
This commit is contained in:
parent
f181af8547
commit
3585d861ff
4 changed files with 21 additions and 9 deletions
|
@ -33,6 +33,7 @@ _srcfile = os.path.normcase(_srcfile)
|
|||
|
||||
|
||||
session = FuturesSession()
|
||||
TRACE = 5
|
||||
|
||||
|
||||
def bg_cb(sess, resp):
|
||||
|
@ -371,5 +372,10 @@ class Logger(logging.Logger):
|
|||
callback(err, *args, **kwargs)
|
||||
return _fail
|
||||
|
||||
def trace(self, msg, *args, **kwargs):
|
||||
if self.isEnabledFor(TRACE):
|
||||
self._log(TRACE, msg, args, **kwargs)
|
||||
|
||||
|
||||
logging.setLoggerClass(Logger)
|
||||
logging.addLevelName(TRACE, 'TRACE')
|
||||
|
|
|
@ -64,7 +64,7 @@ class ServerProtocol(Protocol):
|
|||
self.transport.loseConnection()
|
||||
|
||||
def write(self, data):
|
||||
log.debug("Writing %s bytes of data to the transport", str(len(data)))
|
||||
log.trace("Writing %s bytes of data to the transport", len(data))
|
||||
self.transport.write(data)
|
||||
self.factory.rate_limiter.report_ul_bytes(len(data))
|
||||
|
||||
|
|
|
@ -52,13 +52,15 @@ class ServerRequestHandler(object):
|
|||
|
||||
from twisted.internet import reactor
|
||||
|
||||
if self.production_paused is False:
|
||||
chunk = self.response_buff[:self.CHUNK_SIZE]
|
||||
self.response_buff = self.response_buff[self.CHUNK_SIZE:]
|
||||
if chunk != '':
|
||||
log.debug("writing %s bytes to the client", str(len(chunk)))
|
||||
self.consumer.write(chunk)
|
||||
reactor.callLater(0, self._produce_more)
|
||||
if self.production_paused:
|
||||
return
|
||||
chunk = self.response_buff[:self.CHUNK_SIZE]
|
||||
self.response_buff = self.response_buff[self.CHUNK_SIZE:]
|
||||
if chunk == '':
|
||||
return
|
||||
log.trace("writing %s bytes to the client", len(chunk))
|
||||
self.consumer.write(chunk)
|
||||
reactor.callLater(0, self._produce_more)
|
||||
|
||||
#IConsumer stuff
|
||||
|
||||
|
@ -79,7 +81,7 @@ class ServerRequestHandler(object):
|
|||
|
||||
def get_more_data():
|
||||
if self.producer is not None:
|
||||
log.debug("Requesting more data from the producer")
|
||||
log.trace("Requesting more data from the producer")
|
||||
self.producer.resumeProducing()
|
||||
|
||||
reactor.callLater(0, get_more_data)
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
# log_support setups the default Logger class
|
||||
# and so we need to ensure that it is also
|
||||
# setup for the tests
|
||||
from lbrynet.core import log_support
|
Loading…
Reference in a new issue