print error message in report

parent 517c0dde
Pipeline #18461 passed with stages
in 8 minutes and 17 seconds
......@@ -66,7 +66,7 @@ object App extends scala.App with Logging with RecordUtils {
processed <- recordProcessor.process(record)
} yield (record, processed) match {
case (rec, ProcessSuccess(id, msg)) =>
logger.debug(s"$id: $msg")
logger.info(s"$id: $msg")
reporter.send(ReportingObject(id, ProcessingSuccess, msg, getInstitutionAndRecordSet(rec.value)))
case (rec, ProcessIgnore(id, msg)) =>
logger.info(s"$id: $msg")
......@@ -77,7 +77,7 @@ object App extends scala.App with Logging with RecordUtils {
case (rec, ProcessFatal(id, msg, ex)) =>
logger.error(s"$id: $msg: ${ex.getMessage}")
logger.debug(ex.getStackTrace.mkString("\n"))
reporter.send(ReportingObject(id, ProcessingFatal, msg, getInstitutionAndRecordSet(rec.value)))
reporter.send(ReportingObject(id, ProcessingFatal, s"$msg: ${ex.getMessage}", getInstitutionAndRecordSet(rec.value)))
}
}
} catch {
......
......@@ -46,24 +46,22 @@ case object ProcessingFatal extends ProcessingStatus {
case class ReportingObject(id: String, status: ProcessingStatus, message: String, institutionRecordSet: (Option[String], Option[String])) {
import ReportingObject._
import ReportingObject.createTimestamp
override def toString: String =
s"""{"step": "media-converter", "timestamp": "$createTimestamp", "id": "https://memobase.ch/digital/$id", "status": "${
status match {
case ProcessingSuccess => ProcessingSuccess.value
case ProcessingWarning => ProcessingWarning.value
case ProcessingIgnore => ProcessingIgnore.value
case ProcessingFatal => ProcessingFatal.value
}
}", "message": "${escapeApostrophes(message)}"}"""
ujson.write(
ujson.Obj(
("step", "media-metadata-extractor"),
("timestamp", createTimestamp),
("id", id),
("status", status.value),
("message", message)
)
)
}
object ReportingObject {
val dateFormatter = new SimpleDateFormat("YYYY-MM-dd'T'HH:mm:ss.SSS")
private val dateFormatter = new SimpleDateFormat("YYYY-MM-dd'T'HH:mm:ss.SSS")
def createTimestamp: String = dateFormatter.format(Calendar.getInstance().getTime)
def escapeApostrophes(value: String): String =
value.replaceAll(""""""", """\\"""")
}
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