diff --git a/swift/account/auditor.py b/swift/account/auditor.py index 3410089d..e93e8a9c 100644 --- a/swift/account/auditor.py +++ b/swift/account/auditor.py @@ -118,10 +118,10 @@ class AccountAuditor(Daemon): broker.get_info() self.logger.increment('passes') self.account_passes += 1 - self.logger.debug(_('Audit passed for %s') % broker.db_file) + self.logger.debug(_('Audit passed for %s') % broker) except (Exception, Timeout): self.logger.increment('failures') self.account_failures += 1 self.logger.exception(_('ERROR Could not get account info %s'), - (broker.db_file)) + path) self.logger.timing_since('timing', start_time) diff --git a/swift/common/db.py b/swift/common/db.py index aca0cc6d..5e3b1e22 100644 --- a/swift/common/db.py +++ b/swift/common/db.py @@ -187,6 +187,14 @@ class DatabaseBroker(object): self.container = container self._db_version = -1 + def __str__(self): + """ + Returns a string indentifying the entity under broker to a human. + The baseline implementation returns a full pathname to a database. + This is vital for useful diagnostics. + """ + return self.db_file + def initialize(self, put_timestamp=None): """ Create the DB diff --git a/swift/common/db_replicator.py b/swift/common/db_replicator.py index 1ac38ac5..3481cba4 100644 --- a/swift/common/db_replicator.py +++ b/swift/common/db_replicator.py @@ -296,8 +296,8 @@ class Replicator(Daemon): if objects: self.logger.debug(_( 'Synchronization for %s has fallen more than ' - '%s rows behind; moving on and will try again next pass.') % - (broker.db_file, self.max_diffs * self.per_diff)) + '%s rows behind; moving on and will try again next pass.'), + broker, self.max_diffs * self.per_diff) self.stats['diff_capped'] += 1 self.logger.increment('diff_caps') else: @@ -606,7 +606,7 @@ class ReplicatorRpc(object): info = broker.get_replication_info() except (Exception, Timeout) as e: if 'no such table' in str(e): - self.logger.error(_("Quarantining DB %s") % broker.db_file) + self.logger.error(_("Quarantining DB %s"), broker) quarantine_db(broker.db_file, broker.db_type) return HTTPNotFound() raise diff --git a/swift/container/auditor.py b/swift/container/auditor.py index f0d414fe..62491a39 100644 --- a/swift/container/auditor.py +++ b/swift/container/auditor.py @@ -118,10 +118,10 @@ class ContainerAuditor(Daemon): broker.get_info() self.logger.increment('passes') self.container_passes += 1 - self.logger.debug(_('Audit passed for %s'), broker.db_file) + self.logger.debug(_('Audit passed for %s'), broker) except (Exception, Timeout): self.logger.increment('failures') self.container_failures += 1 self.logger.exception(_('ERROR Could not get container info %s'), - broker.db_file) + path) self.logger.timing_since('timing', start_time) diff --git a/swift/container/sync.py b/swift/container/sync.py index 9594c852..5fd7b34c 100644 --- a/swift/container/sync.py +++ b/swift/container/sync.py @@ -245,7 +245,7 @@ class ContainerSync(Daemon): if err: self.logger.info( _('ERROR %(db_file)s: %(validate_sync_to_err)s'), - {'db_file': broker.db_file, + {'db_file': str(broker), 'validate_sync_to_err': err}) self.container_failures += 1 self.logger.increment('failures') @@ -299,7 +299,7 @@ class ContainerSync(Daemon): self.container_failures += 1 self.logger.increment('failures') self.logger.exception(_('ERROR Syncing %s'), - broker.db_file if broker else path) + broker if broker else path) def container_sync_row(self, row, sync_to, sync_key, broker, info): """ @@ -397,14 +397,14 @@ class ContainerSync(Daemon): else: self.logger.exception( _('ERROR Syncing %(db_file)s %(row)s'), - {'db_file': broker.db_file, 'row': row}) + {'db_file': str(broker), 'row': row}) self.container_failures += 1 self.logger.increment('failures') return False except (Exception, Timeout) as err: self.logger.exception( _('ERROR Syncing %(db_file)s %(row)s'), - {'db_file': broker.db_file, 'row': row}) + {'db_file': str(broker), 'row': row}) self.container_failures += 1 self.logger.increment('failures') return False