Platform: PlatformLogger - Dani-error/velar GitHub Wiki
📘 PlatformLogger
PlatformLogger
?
🔧 What is PlatformLogger
is an abstraction layer for platform-specific logging used internally in velar. It provides consistent log formatting across different server implementations while allowing you to integrate with your own logging system if needed.
🧱 Interface Methods
Method | Description |
---|---|
info(message: String) |
Logs an informational message. |
warning(message: String) |
Logs a warning. |
error(message: String) |
Logs an error message. |
error(message: String, exception: Throwable?) |
Logs an error with an optional stack trace. |
🚀 Built-in Implementations
-
PlatformLogger.nop()
Returns a no-op logger that ignores all log calls. Useful for silent mode/testing. -
PlatformLogger.fromJul(logger: java.util.logging.Logger)
Wraps an existingjava.util.logging.Logger
into aPlatformLogger
.
🧩 Custom Implementation Example
You can create your own logger to integrate with another system:
class PlatformLoggerCustom : PlatformLogger {
override fun info(message: String) = println("[INFO] $message")
override fun warning(message: String) = println("[WARN] $message")
override fun error(message: String) = println("[ERROR] $message")
override fun error(message: String, exception: Throwable?) {
println("[ERROR] $message")
exception?.printStackTrace()
}
}
Just pass it to the platform builder:
.logger(PlatformLoggerCustom())
.build()