Verified Commit 2f946fa0 authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files

log more verbosly

parent 79d5be61
Pipeline #37776 passed with stages
in 5 minutes and 26 seconds
...@@ -44,7 +44,7 @@ trait BinaryHandler { ...@@ -44,7 +44,7 @@ trait BinaryHandler {
) )
.foldLeft[List[String]](List())((errors, x) => .foldLeft[List[String]](List())((errors, x) =>
if (!x._1) { if (!x._1) {
logger.warn(s"Deletion of file ${x._2} failed!") logger.warn(s"Deletion of file ${x._2} failed${if (record.dryRun) " (dry-run mode)" else ""}!")
errors :+ s"${x._2} deletion failed" errors :+ s"${x._2} deletion failed"
} else { } else {
errors errors
...@@ -52,7 +52,7 @@ trait BinaryHandler { ...@@ -52,7 +52,7 @@ trait BinaryHandler {
) )
if (result.isEmpty) { if (result.isEmpty) {
logger.debug( logger.debug(
s"Deletion of binaries for record ${record.recordId} successful" s"Deletion of binaries for record ${record.recordId} successful${if (record.dryRun) " (dry-run mode)" else ""}"
) )
record.setBinariesStatus( record.setBinariesStatus(
ProcessingSuccess, ProcessingSuccess,
...@@ -60,7 +60,7 @@ trait BinaryHandler { ...@@ -60,7 +60,7 @@ trait BinaryHandler {
) )
} else { } else {
logger.warn( logger.warn(
s"Deletion of binaries for record ${record.recordId} failed" s"Deletion of binaries for record ${record.recordId} failed${if (record.dryRun) " (dry-run mode)" else ""}"
) )
record.setBinariesStatus(ProcessingFatal, result.mkString("; ")) record.setBinariesStatus(ProcessingFatal, result.mkString("; "))
} }
......
...@@ -51,14 +51,38 @@ trait MariadbClient { ...@@ -51,14 +51,38 @@ trait MariadbClient {
manifestV3Table: Boolean manifestV3Table: Boolean
): String = { ): String = {
s"$resourceName entry deleted in tables " + s"$resourceName entry deleted in tables " +
s"${if (entitiesTable) { "entities, " } s"${
else { "" }}" + if (entitiesTable) {
s"${if (metadataTable) { "metadata, " } "entities, "
else { "" }}" + }
s"${if (manifestV2Table) { "iiif_manifests_v2, " } else {
else { "" }}" + ""
s"${if (manifestV3Table) { "iiif_manifests_v3" } }
else { "" }}" }" +
s"${
if (metadataTable) {
"metadata, "
}
else {
""
}
}" +
s"${
if (manifestV2Table) {
"iiif_manifests_v2, "
}
else {
""
}
}" +
s"${
if (manifestV3Table) {
"iiif_manifests_v3"
}
else {
""
}
}"
} }
private def updateDigitalObjectResult( private def updateDigitalObjectResult(
...@@ -89,7 +113,7 @@ trait MariadbClient { ...@@ -89,7 +113,7 @@ trait MariadbClient {
case Failure(ex) => case Failure(ex) =>
record.setDigitalObjectStatus( record.setDigitalObjectStatus(
ProcessingFatal, ProcessingFatal,
s"Digital object media DB entries deletion failed: ${ex.getMessage}" s"Digital object media DB entries deletion failed${if (record.dryRun) " (dry-run mode)" else ""}: ${ex.getMessage}"
) )
} }
...@@ -106,13 +130,13 @@ trait MariadbClient { ...@@ -106,13 +130,13 @@ trait MariadbClient {
// Something went wrong // Something went wrong
record.setThumbnailStatus( record.setThumbnailStatus(
ProcessingFatal, ProcessingFatal,
s"Poster entries deletion failed: ${e.getMessage}" s"Poster entries deletion failed${if (record.dryRun) " (dry-run mode)" else ""}: ${e.getMessage}"
) )
case (_, Failure(e)) => case (_, Failure(e)) =>
// Something went wrong // Something went wrong
record.setThumbnailStatus( record.setThumbnailStatus(
ProcessingFatal, ProcessingFatal,
s"Snippet entries deletion failed: ${e.getMessage}" s"Snippet entries deletion failed${if (record.dryRun) " (dry-run mode)" else ""}: ${e.getMessage}"
) )
case (`noRows`, `noRows`) => case (`noRows`, `noRows`) =>
record.setThumbnailStatus(ProcessingIgnore, "No thumbnails found") record.setThumbnailStatus(ProcessingIgnore, "No thumbnails found")
...@@ -189,6 +213,7 @@ trait MariadbClient { ...@@ -189,6 +213,7 @@ trait MariadbClient {
Try(connection.commit()) Try(connection.commit())
}) match { }) match {
case Success(_) => case Success(_) =>
logger.debug(s"MariaDB entries for record ${record.recordId} successfully deleted${if (record.dryRun) " (dry-run mode)" else ""}.")
val updatedRecord = updateDigitalObjectResult( val updatedRecord = updateDigitalObjectResult(
record, record,
digitalObjectDeletionResult digitalObjectDeletionResult
...@@ -199,6 +224,7 @@ trait MariadbClient { ...@@ -199,6 +224,7 @@ trait MariadbClient {
introDeletionResult introDeletionResult
) )
case Failure(ex) => case Failure(ex) =>
logger.warn(s"Deletion of MariaDB entries for record ${record.recordId} failed${if (record.dryRun) " (dry-run mode)" else ""}: ${ex.getMessage}.")
val updatedRecord = updateDigitalObjectResult( val updatedRecord = updateDigitalObjectResult(
record, record,
Failure(ex) Failure(ex)
...@@ -228,6 +254,7 @@ trait MariadbClient { ...@@ -228,6 +254,7 @@ trait MariadbClient {
/** /**
* Deletes related rows * Deletes related rows
*
* @param id Record's id * @param id Record's id
* @return An optional media file URI and success status for each row * @return An optional media file URI and success status for each row
*/ */
......
...@@ -73,23 +73,23 @@ trait MemobaseElasticClient { ...@@ -73,23 +73,23 @@ trait MemobaseElasticClient {
} }
.map { .map {
case success: RequestSuccess[_] if success.status < 400 => case success: RequestSuccess[_] if success.status < 400 =>
logger.debug(s"Deletion of record ${record.recordId} successful") logger.debug(s"Deletion of record ${record.recordId} successful${if (record.dryRun) " (dry-run mode)" else ""}")
record.setRecordStatus( record.setRecordStatus(
ProcessingSuccess, ProcessingSuccess,
"Record deletion in Elasticsearch successful" "Record deletion in Elasticsearch successful"
) )
case _: RequestSuccess[_] => case _: RequestSuccess[_] =>
logger.debug(s"Deletion of record ${record.recordId} failed since record does not exist") logger.debug(s"Deletion of record ${record.recordId} failed since record does not exist${if (record.dryRun) " (dry-run mode)" else ""}")
record.setRecordStatus( record.setRecordStatus(
ProcessingIgnore, ProcessingIgnore,
"Record does not exist in Elasticearch" "Record does not exist in Elasticearch"
) )
case failure: RequestFailure => case failure: RequestFailure =>
logger.warn(s"Deletion of record ${record.recordId} failed: ${failure.error.reason}") logger.warn(s"Deletion of record ${record.recordId} failed${if (record.dryRun) " (dry-run mode)" else ""}: ${failure.error.reason}")
record.setRecordStatus( record.setRecordStatus(
ProcessingFatal, ProcessingFatal,
s"Record deletion in Elasticsearch failed: ${failure.error.reason}" s"Record deletion in Elasticsearch failed${if (record.dryRun) " (dry-run mode)" else ""}: ${failure.error.reason}"
) )
} }
.await .await
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment