Revert "more logging on the server side"

This reverts commit f83daa5a22.
This commit is contained in:
Job Evers-Meltzer 2016-08-11 05:11:18 +00:00
parent defbd73b4f
commit 80f27f2b29
5 changed files with 18 additions and 25 deletions

View file

@ -1,2 +1,8 @@
import logging
log = logging.getLogger(__name__)
logging.getLogger(__name__).addHandler(logging.NullHandler())
log.setLevel(logging.INFO)
__version__ = "0.3.17" __version__ = "0.3.17"
version = tuple(__version__.split('.')) version = tuple(__version__.split('.'))

View file

@ -58,10 +58,8 @@ def _log_decorator(fn):
handler = fn(*args, **kwargs) handler = fn(*args, **kwargs)
if handler.name: if handler.name:
remove_handlers(log, handler.name) remove_handlers(log, handler.name)
handler.setLevel(level)
log.addHandler(handler) log.addHandler(handler)
if log.level > level: log.setLevel(level)
log.setLevel(level)
return helper return helper

View file

@ -213,7 +213,7 @@ class LBRYDaemon(jsonrpc.JSONRPC):
'use_upnp': True, 'use_upnp': True,
'start_lbrycrdd': True, 'start_lbrycrdd': True,
'requested_first_run_credits': False, 'requested_first_run_credits': False,
'run_reflector_server': True, 'run_reflector_server': False,
'cache_time': DEFAULT_CACHE_TIME, 'cache_time': DEFAULT_CACHE_TIME,
'startup_scripts': [], 'startup_scripts': [],
'last_version': {'lbrynet': lbrynet_version, 'lbryum': lbryum_version} 'last_version': {'lbrynet': lbrynet_version, 'lbryum': lbryum_version}
@ -683,8 +683,8 @@ class LBRYDaemon(jsonrpc.JSONRPC):
def _start_reflector(self): def _start_reflector(self):
if self.run_reflector_server: if self.run_reflector_server:
log.info("Starting reflector server")
if self.reflector_port is not None: if self.reflector_port is not None:
log.info("Starting reflector server listening to %s", self.reflector_port)
reflector_factory = reflector.ServerFactory( reflector_factory = reflector.ServerFactory(
self.session.peer_manager, self.session.peer_manager,
self.session.blob_manager self.session.blob_manager

View file

@ -74,8 +74,8 @@ def start():
args = parser.parse_args() args = parser.parse_args()
log_support.disable_noisy_loggers() log_support.disable_noisy_loggers()
log_support.configure_file_handler(lbrynet_log, level=10) log_support.configure_file_handler(lbrynet_log)
log_support.configure_loggly_handler(level=10) log_support.configure_loggly_handler()
if args.logtoconsole: if args.logtoconsole:
log_support.configure_console(level='DEBUG') log_support.configure_console(level='DEBUG')

View file

@ -11,9 +11,9 @@ log = logging.getLogger(__name__)
class ReflectorServer(Protocol): class ReflectorServer(Protocol):
def connectionMade(self): def connectionMade(self):
peer_info = self.transport.getPeer() peer_info = self.transport.getPeer()
log.debug('Connection made to %s', peer_info)
self.peer = self.factory.peer_manager.get_peer(peer_info.host, peer_info.port) self.peer = self.factory.peer_manager.get_peer(peer_info.host, peer_info.port)
self.blob_manager = self.factory.blob_manager self.blob_manager = self.factory.blob_manager
self.received_handshake = False self.received_handshake = False
@ -29,21 +29,17 @@ class ReflectorServer(Protocol):
pass pass
def dataReceived(self, data): def dataReceived(self, data):
log.debug('Recieved data: %s', data) if self.receiving_blob is False:
if self.receiving_blob:
log.debug('Writing data to blob')
self.blob_write(data)
else:
log.debug('Not yet recieving blob, data needs further processing')
self.request_buff += data self.request_buff += data
msg, extra_data = self._get_valid_response(self.request_buff) msg, extra_data = self._get_valid_response(self.request_buff)
if msg: if msg is not None:
self.request_buff = '' self.request_buff = ''
d = self.handle_request(msg) d = self.handle_request(msg)
d.addCallbacks(self.send_response, self.handle_error) d.addCallbacks(self.send_response, self.handle_error)
if self.receiving_blob and extra_data: if self.receiving_blob is True and len(extra_data) != 0:
log.debug('Writing extra data to blog')
self.blob_write(extra_data) self.blob_write(extra_data)
else:
self.blob_write(data)
def _get_valid_response(self, response_msg): def _get_valid_response(self, response_msg):
extra_data = None extra_data = None
@ -74,7 +70,6 @@ class ReflectorServer(Protocol):
return self.handle_normal_request(request_dict) return self.handle_normal_request(request_dict)
def handle_handshake(self, request_dict): def handle_handshake(self, request_dict):
log.debug('Handling handshake')
if 'version' not in request_dict: if 'version' not in request_dict:
raise ValueError("Client should send version") raise ValueError("Client should send version")
self.peer_version = int(request_dict['version']) self.peer_version = int(request_dict['version'])
@ -108,7 +103,6 @@ class ReflectorServer(Protocol):
raise ValueError("Expected a blob hash and a blob size") raise ValueError("Expected a blob hash and a blob size")
if not is_valid_blobhash(request_dict['blob_hash']): if not is_valid_blobhash(request_dict['blob_hash']):
raise ValueError("Got a bad blob hash: {}".format(request_dict['blob_hash'])) raise ValueError("Got a bad blob hash: {}".format(request_dict['blob_hash']))
log.debug('Recieved info for blob: %s', request_dict['blob_hash'])
d = self.blob_manager.get_blob( d = self.blob_manager.get_blob(
request_dict['blob_hash'], request_dict['blob_hash'],
True, True,
@ -120,7 +114,6 @@ class ReflectorServer(Protocol):
# important in it. to the deferred that fires when the blob is done, # important in it. to the deferred that fires when the blob is done,
# add a callback which returns a nice response dict saying to keep # add a callback which returns a nice response dict saying to keep
# sending, and then return that deferred # sending, and then return that deferred
log.debug('blob is already open')
self.receiving_blob = True self.receiving_blob = True
d = self.blob_finished_d d = self.blob_finished_d
d.addCallback(lambda _: self.close_blob()) d.addCallback(lambda _: self.close_blob())
@ -141,7 +134,3 @@ class ReflectorServerFactory(ServerFactory):
def __init__(self, peer_manager, blob_manager): def __init__(self, peer_manager, blob_manager):
self.peer_manager = peer_manager self.peer_manager = peer_manager
self.blob_manager = blob_manager self.blob_manager = blob_manager
def buildProtocol(self, addr):
log.debug('Creating a protocol for %s', addr)
ServerFactory.buildProtocol(self, addr)