commit 3ee6b65a8e29c4675fff5c10d5f258c27aff051c parent 2daf4029d66d72e497d2fd70285ef64b5d52337a Author: Antoine A <> Date: Tue, 21 Oct 2025 15:30:28 +0200 common: skip logging timestamp if systemd is used Diffstat:
| M | common/src/main/kotlin/log.kt | | | 13 | +++++++++---- |
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/common/src/main/kotlin/log.kt b/common/src/main/kotlin/log.kt @@ -56,12 +56,14 @@ class TalerLogger(private val loggerName: String): LegacyAbstractLogger() { ) return val callId = org.slf4j.MDC.get("call-id") val logEntry = buildString { - append(LocalDateTime.now().format(dateFormatter)) - if (callId != null) { + if (timestampFmt != null) { + append(LocalDateTime.now().format(timestampFmt)) append(' ') + } + if (callId != null) { append(callId) + append(' ') } - append(' ') append(level.name.padEnd(5)) append(' ') append(name) @@ -80,7 +82,10 @@ class TalerLogger(private val loggerName: String): LegacyAbstractLogger() { } companion object { - private val dateFormatter = DateTimeFormatter.ofPattern("dd-MMM-yyyy'T'HH:mm:ss.SSS") + // We skip logging timestamp if systemd is used + private val skipTimestamp = System.getenv("JOURNAL_STREAM") != null + // A null timestamp formatter mean we should skip it + private val timestampFmt = if (skipTimestamp) null else DateTimeFormatter.ofPattern("dd-MMM-yyyy'T'HH:mm:ss.SSS") } }