Adjustment to error logging

This commit is contained in:
Brage 2023-07-31 01:47:29 +02:00
parent a174fe2aea
commit a395efdbd9
2 changed files with 6 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package no.iktdev.streamit.content.convert
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import mu.KotlinLogging
import no.iktdev.library.subtitle.Syncro import no.iktdev.library.subtitle.Syncro
import no.iktdev.library.subtitle.export.Export import no.iktdev.library.subtitle.export.Export
import no.iktdev.library.subtitle.reader.BaseReader import no.iktdev.library.subtitle.reader.BaseReader
@ -11,6 +12,9 @@ import no.iktdev.streamit.content.common.dto.reader.work.ConvertWork
import no.iktdev.streamit.content.common.dto.reader.work.ExtractWork import no.iktdev.streamit.content.common.dto.reader.work.ExtractWork
import java.io.File import java.io.File
private val logger = KotlinLogging.logger {}
class ConvertRunner(val referenceId: String, val listener: IConvertListener) { class ConvertRunner(val referenceId: String, val listener: IConvertListener) {
private fun getReade(inputFile: File): BaseReader? { private fun getReade(inputFile: File): BaseReader? {
@ -22,6 +26,7 @@ class ConvertRunner(val referenceId: String, val listener: IConvertListener) {
val reader = getReade(inFile) val reader = getReade(inFile)
val dialogs = reader?.read() val dialogs = reader?.read()
if (dialogs.isNullOrEmpty()) { if (dialogs.isNullOrEmpty()) {
logger.error { "$referenceId ${subtitleInfo.inputFile}: Dialogs read from file is null or empty!" }
withContext(Dispatchers.Default) { withContext(Dispatchers.Default) {
listener.onError(referenceId, subtitleInfo, "Dialogs read from file is null or empty!") listener.onError(referenceId, subtitleInfo, "Dialogs read from file is null or empty!")
} }

View File

@ -59,7 +59,7 @@ class SubtitleConsumer: DefaultKafkaReader("convertHandlerSubtitle"), IConvertLi
} }
override fun onError(referenceId: String, info: SubtitleInfo, message: String) { override fun onError(referenceId: String, info: SubtitleInfo, message: String) {
produceMessage(KafkaEvents.EVENT_CONVERTER_SUBTITLE_FILE_ENDED, Message(referenceId = referenceId, Status(statusType = StatusType.ERROR)), null) produceMessage(KafkaEvents.EVENT_CONVERTER_SUBTITLE_FILE_ENDED, Message(referenceId = referenceId, Status(statusType = StatusType.ERROR, message = message)), null)
} }
override fun onEnded(referenceId: String, info: SubtitleInfo, work: ConvertWork) { override fun onEnded(referenceId: String, info: SubtitleInfo, work: ConvertWork) {