Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

models: logging strings unicode-friendly #143

Merged
merged 1 commit into from
Jul 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions invenio_pidstore/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ def create(cls, pid_type, pid_value, pid_provider=None,
if object_type and object_uuid:
obj.assign(object_type, object_uuid)
db.session.add(obj)
logger.info("Created PID {0}:{1}".format(pid_type, pid_value),
logger.info(u"Created PID {0}:{1}".format(pid_type, pid_value),
extra={'pid': obj})
except IntegrityError:
logger.exception(
"PID already exists: {0}:{1}".format(pid_type, pid_value),
u"PID already exists: {0}:{1}".format(pid_type, pid_value),
extra=dict(
pid_type=pid_type,
pid_value=pid_value,
Expand All @@ -163,7 +163,7 @@ def create(cls, pid_type, pid_value, pid_provider=None,
raise PIDAlreadyExists(pid_type=pid_type, pid_value=pid_value)
except SQLAlchemyError:
logger.exception(
"Failed to create PID: {0}:{1}".format(pid_type, pid_value),
u"Failed to create PID: {0}:{1}".format(pid_type, pid_value),
extra=dict(
pid_type=pid_type,
pid_value=pid_value,
Expand Down Expand Up @@ -281,10 +281,10 @@ def assign(self, object_type, object_uuid, overwrite=False):
self.object_uuid = object_uuid
db.session.add(self)
except SQLAlchemyError:
logger.exception("Failed to assign {0}:{1}".format(
logger.exception(u"Failed to assign {0}:{1}".format(
object_type, object_uuid), extra=dict(pid=self))
raise
logger.info("Assigned object {0}:{1}".format(
logger.info(u"Assigned object {0}:{1}".format(
object_type, object_uuid), extra=dict(pid=self))
return True

Expand All @@ -311,10 +311,10 @@ def unassign(self):
self.object_uuid = None
db.session.add(self)
except SQLAlchemyError:
logger.exception("Failed to unassign object.".format(self),
logger.exception(u"Failed to unassign object.".format(self),
extra=dict(pid=self))
raise
logger.info("Unassigned object from {0}.".format(self),
logger.info(u"Unassigned object from {0}.".format(self),
extra=dict(pid=self))
return True

Expand Down Expand Up @@ -360,10 +360,10 @@ def redirect(self, pid):
except IntegrityError:
raise PIDDoesNotExistError(pid.pid_type, pid.pid_value)
except SQLAlchemyError:
logger.exception("Failed to redirect to {0}".format(
logger.exception(u"Failed to redirect to {0}".format(
pid), extra=dict(pid=self))
raise
logger.info("Redirected PID to {0}".format(pid), extra=dict(pid=self))
logger.info(u"Redirected PID to {0}".format(pid), extra=dict(pid=self))
return True

def reserve(self):
Expand Down Expand Up @@ -460,10 +460,10 @@ def sync_status(self, status):
self.status = status
db.session.add(self)
except SQLAlchemyError:
logger.exception("Failed to sync status {0}.".format(status),
logger.exception(u"Failed to sync status {0}.".format(status),
extra=dict(pid=self))
raise
logger.info("Synced PID status to {0}.".format(status),
logger.info(u"Synced PID status to {0}.".format(status),
extra=dict(pid=self))
return True

Expand Down