Log fiks
This commit is contained in:
parent
f3d42c06d2
commit
fd468520d5
@ -5,6 +5,7 @@ import com.github.pgreze.process.process
|
|||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
|
import mu.KotlinLogging
|
||||||
import no.iktdev.exfl.coroutines.Coroutines
|
import no.iktdev.exfl.coroutines.Coroutines
|
||||||
import no.iktdev.exfl.using
|
import no.iktdev.exfl.using
|
||||||
import no.iktdev.mediaprocessing.processer.ProcesserEnv
|
import no.iktdev.mediaprocessing.processer.ProcesserEnv
|
||||||
@ -15,6 +16,8 @@ class FfmpegWorker(val referenceId: String, val eventId: String, val info: Ffmpe
|
|||||||
val scope = Coroutines.io()
|
val scope = Coroutines.io()
|
||||||
val decoder = FfmpegProgressDecoder()
|
val decoder = FfmpegProgressDecoder()
|
||||||
private val outputCache = mutableListOf<String>()
|
private val outputCache = mutableListOf<String>()
|
||||||
|
private val log = KotlinLogging.logger {}
|
||||||
|
|
||||||
val logFile = logDir.using("$eventId-=-${File(info.outFile).nameWithoutExtension}.log")
|
val logFile = logDir.using("$eventId-=-${File(info.outFile).nameWithoutExtension}.log")
|
||||||
|
|
||||||
val getOutputCache = outputCache.toList()
|
val getOutputCache = outputCache.toList()
|
||||||
@ -62,17 +65,12 @@ class FfmpegWorker(val referenceId: String, val eventId: String, val info: Ffmpe
|
|||||||
stdout = Redirect.CAPTURE,
|
stdout = Redirect.CAPTURE,
|
||||||
stderr = Redirect.CAPTURE,
|
stderr = Redirect.CAPTURE,
|
||||||
consumer = {
|
consumer = {
|
||||||
|
//log.info { it }
|
||||||
onOutputChanged(it)
|
onOutputChanged(it)
|
||||||
},
|
},
|
||||||
destroyForcibly = true)
|
destroyForcibly = true)
|
||||||
|
|
||||||
val result = processOp
|
val result = processOp
|
||||||
println(Gson().toJson(result))
|
|
||||||
if (outputCache.isEmpty()) {
|
|
||||||
result.output.forEach {
|
|
||||||
onOutputChanged(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onOutputChanged("Received exit code: ${result.resultCode}")
|
onOutputChanged("Received exit code: ${result.resultCode}")
|
||||||
if (result.resultCode != 0) {
|
if (result.resultCode != 0) {
|
||||||
listener.onError(info, result.output.joinToString("\n"))
|
listener.onError(info, result.output.joinToString("\n"))
|
||||||
@ -90,7 +88,7 @@ class FfmpegWorker(val referenceId: String, val eventId: String, val info: Ffmpe
|
|||||||
|
|
||||||
fun writeToLog(line: String) {
|
fun writeToLog(line: String) {
|
||||||
logFile.printWriter().use {
|
logFile.printWriter().use {
|
||||||
it.println(line)
|
it.appendLine(line)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -38,9 +38,11 @@ class Preference {
|
|||||||
if (!prefFile.exists()) {
|
if (!prefFile.exists()) {
|
||||||
log.info("Preference file: ${prefFile.absolutePath} does not exists...")
|
log.info("Preference file: ${prefFile.absolutePath} does not exists...")
|
||||||
log.info("Using default configuration")
|
log.info("Using default configuration")
|
||||||
val gson = GsonBuilder().setPrettyPrinting().create()
|
silentTry {
|
||||||
SharedConfig.preference.printWriter().use { out ->
|
val gson = GsonBuilder().setPrettyPrinting().create()
|
||||||
out.print(gson.toJson(PreferenceDto()))
|
SharedConfig.preference.printWriter().use { out ->
|
||||||
|
out.print(gson.toJson(PreferenceDto()))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,3 +65,9 @@ fun getComputername(): String {
|
|||||||
|
|
||||||
return (envs + netHostname).firstOrNull() ?: "UNKNOWN_SYSTEM"
|
return (envs + netHostname).firstOrNull() ?: "UNKNOWN_SYSTEM"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun silentTry(code: () -> Unit) {
|
||||||
|
try {
|
||||||
|
code.invoke()
|
||||||
|
} catch (_: Exception) {}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user