Merge branch 'remove-file-name-logging'

This commit is contained in:
Jack Robison 2017-12-06 15:12:46 -05:00
commit eb3e1a195f
No known key found for this signature in database
GPG key ID: 284699E7404E3CFF
3 changed files with 23 additions and 27 deletions

View file

@ -31,6 +31,7 @@ at anytime.
* Increased assumption for time it takes to announce single hash from 1 second to 5 seconds
* Don't set HTTP error codes for failed api requests, conform to http://www.jsonrpc.org/specification#error_object
* Return less verbose tracebacks for api requests resulting in errors
* Don't include file names when logging information about streams, only include sd hashes
### Added
* Added `channel_import` and `channel_export` commands

View file

@ -19,7 +19,7 @@ from lbrynet.lbry_file.StreamDescriptor import save_sd_info
log = logging.getLogger(__name__)
def log_status(file_name, sd_hash, status):
def log_status(sd_hash, status):
if status == ManagedEncryptedFileDownloader.STATUS_RUNNING:
status_string = "running"
elif status == ManagedEncryptedFileDownloader.STATUS_STOPPED:
@ -28,7 +28,7 @@ def log_status(file_name, sd_hash, status):
status_string = "finished"
else:
status_string = "unknown"
log.info("%s (%s) is %s", file_name, short_hash(sd_hash), status_string)
log.info("stream %s is %s", short_hash(sd_hash), status_string)
class ManagedEncryptedFileDownloader(EncryptedFileSaver):
@ -60,7 +60,7 @@ class ManagedEncryptedFileDownloader(EncryptedFileSaver):
yield self.load_file_attributes()
status = yield self.lbry_file_manager.get_lbry_file_status(self)
log_status(self.file_name, self.sd_hash, status)
log_status(self.sd_hash, status)
if status == ManagedEncryptedFileDownloader.STATUS_RUNNING:
# start returns self.finished_deferred
@ -119,7 +119,7 @@ class ManagedEncryptedFileDownloader(EncryptedFileSaver):
yield EncryptedFileSaver._start(self)
yield self.load_file_attributes()
status = yield self._save_status()
log_status(self.file_name, self.sd_hash, status)
log_status(self.sd_hash, status)
defer.returnValue(status)
def _get_finished_deferred_callback_value(self):

View file

@ -76,21 +76,20 @@ class EncryptedFileReflectorClient(Protocol):
if reason.check(error.ConnectionDone):
if not self.needed_blobs:
log.info("Reflector has all blobs for %s (%s)",
self.file_name, self.stream_descriptor)
log.info("Reflector has all blobs for %s", self.stream_descriptor)
elif not self.reflected_blobs:
log.info("No more completed blobs for %s (%s) to reflect, %i are still needed",
self.file_name, self.stream_descriptor, len(self.needed_blobs))
log.info("No more completed blobs for %s to reflect, %i are still needed",
self.stream_descriptor, len(self.needed_blobs))
else:
log.info('Finished sending reflector %i blobs for %s (%s)',
len(self.reflected_blobs), self.file_name, self.stream_descriptor)
log.info('Finished sending reflector %i blobs for %s',
len(self.reflected_blobs), self.stream_descriptor)
self.factory.finished_deferred.callback(self.reflected_blobs)
elif reason.check(error.ConnectionLost):
log.warning("Stopped reflecting %s (%s) after sending %i blobs", self.file_name,
log.warning("Stopped reflecting %s after sending %i blobs",
self.stream_descriptor, len(self.reflected_blobs))
self.factory.finished_deferred.callback(self.reflected_blobs)
else:
log.info('Reflector finished for %s (%s): %s', self.file_name, self.stream_descriptor,
log.info('Reflector finished for %s: %s', self.stream_descriptor,
reason)
self.factory.finished_deferred.callback(reason)
@ -131,10 +130,9 @@ class EncryptedFileReflectorClient(Protocol):
def _show_missing_blobs(filtered):
if filtered:
needs_desc = "" if not self.descriptor_needed else "descriptor and "
log.info("Reflector needs %s%i blobs for %s",
log.info("Reflector needs %s%i blobs for stream",
needs_desc,
len(filtered),
self.file_name)
len(filtered))
return filtered
d = self.factory.stream_info_manager.get_blobs_for_stream(self.factory.stream_hash)
@ -226,8 +224,8 @@ class EncryptedFileReflectorClient(Protocol):
self.reflected_blobs.append(self.next_blob_to_send.blob_hash)
log.info("Sent reflector descriptor %s", self.next_blob_to_send)
else:
log.warning("Reflector failed to receive descriptor %s for %s",
self.next_blob_to_send, self.file_name)
log.warning("Reflector failed to receive descriptor %s",
self.next_blob_to_send)
self.blob_hashes_to_send.append(self.next_blob_to_send.blob_hash)
return self.set_not_uploading()
@ -239,8 +237,7 @@ class EncryptedFileReflectorClient(Protocol):
self.file_sender = FileSender()
return defer.succeed(True)
else:
log.warning("Reflector already has %s for %s", self.next_blob_to_send,
self.file_name)
log.warning("Reflector already has %s", self.next_blob_to_send)
return self.set_not_uploading()
else: # Expecting Server Blob Response
if 'received_blob' not in response_dict:
@ -248,11 +245,9 @@ class EncryptedFileReflectorClient(Protocol):
else:
if response_dict['received_blob']:
self.reflected_blobs.append(self.next_blob_to_send.blob_hash)
log.debug("Sent reflector blob %s for %s", self.next_blob_to_send,
self.file_name)
log.debug("Sent reflector blob %s", self.next_blob_to_send)
else:
log.warning("Reflector failed to receive blob %s for %s",
self.next_blob_to_send, self.file_name)
log.warning("Reflector failed to receive blob %s", self.next_blob_to_send)
self.blob_hashes_to_send.append(self.next_blob_to_send.blob_hash)
return self.set_not_uploading()
@ -287,13 +282,13 @@ class EncryptedFileReflectorClient(Protocol):
def skip_missing_blob(self, err, blob_hash):
err.trap(ValueError)
if blob_hash not in self.failed_blob_hashes:
log.warning("Failed to reflect blob %s for %s, reason: %s",
str(blob_hash)[:16], self.file_name, err.getTraceback())
log.warning("Failed to reflect blob %s, reason: %s",
str(blob_hash)[:16], err.getTraceback())
self.blob_hashes_to_send.append(blob_hash)
self.failed_blob_hashes.append(blob_hash)
else:
log.warning("Failed second try reflecting blob %s for %s, giving up, reason: %s",
str(blob_hash)[:16], self.file_name, err.getTraceback())
log.warning("Failed second try reflecting blob %s, giving up, reason: %s",
str(blob_hash)[:16], err.getTraceback())
def send_next_request(self):
if self.file_sender is not None: