NRF Guide

Référence

DiagnosticLog

Journaux applicatifs avec rotation, regroupement des répétitions et suivi des erreurs.

Contexte d’utilisation

ModulePackageSource SDK
Kotlin/JVMfr.nimby.sdkkotlin-client/src/main/kotlin/fr/nimby/sdk/DiagnosticLog.kt

Signatures extraites de la version 0.8.0-alpha.1. Les paramètres, leurs valeurs par défaut et les propriétés de constructeur sont conservés. Les corps des méthodes ne font pas partie de cette référence.

DiagnosticLog

fr.nimby.sdk · class
class DiagnosticLog(val component: String, root: Path = defaultRoot(),
                    private val maximumBytes: Long = 2 * 1024 * 1024)

Production diagnostics, separate from observations and game saves. Never record a successful polling tick. Repeated failures are coalesced, with a count on recovery/change or after 30 seconds. Each write closes the file.

DiagnosticLog.Companion.defaultRoot

fr.nimby.sdk · fun
fun defaultRoot(): Path = System.getenv("NRF_LOG_DIR")?.takeIf { it.isNotBlank() }?.let(Path::of)

DiagnosticLog.Companion.forComponent

fr.nimby.sdk · fun
@Synchronized fun forComponent(name: String): DiagnosticLog = instances.getOrPut(name) { DiagnosticLog(name) }

DiagnosticLog.directory

fr.nimby.sdk · val
val directory: Path = root.resolve(component)

DiagnosticLog.file

fr.nimby.sdk · val
val file: Path = directory.resolve("$component-${ProcessHandle.current().pid()}.log")

DiagnosticLog.write

fr.nimby.sdk · fun
@Synchronized fun write(message: String, failure: Throwable? = null, level: String = if (failure == null) "INFO" else "ERROR")

DiagnosticLog.startApplication

fr.nimby.sdk · fun
fun startApplication(version: String)

Install once at the application entry point, never inside a library loaded into someone else's process. Fatal native crashes remain outside JVM exception handling; a log is not a native crash dump.