Log
object Log
The Log component provides a simple logging API.
Usually, the log Emitter and Sink are separate units.
Library Guide (Log Producers)
Library modules define Categorys to distinguish the types of logs they emit, and produce logs using the Emitter or IdentifiableEmitter interfaces.
Example
enum class LibraryComponent : Log.Category {
A, B
}
class Manager: Log.Emitter {
var logger: Log.Sink<LibraryComponent>? = Log.Sink.Null
fun event() {
logger?.i(LibraryComponent.A) { "Some event" }
}
}Content copied to clipboard
Application Guide (Log Consumers)
Applications consume logs by implementing or using one of the Sink implementations.
Example
val m = Manager()
m.logger = Log.Sink.Default { category, level ->
level >= Log.Level.DEBUG
}Content copied to clipboard
See also
Types
Link copied to clipboard
This interface should be implemented by an identifiable object that can produce logs.
Link copied to clipboard
A shared flow of log events, which can be assigned as a Sink.
Link copied to clipboard
Sink for log entries.