1. Add the necessary dependencies to your module's build.gradle.kts file
2. Create a LogSink
3. Create a Logger
4. Start logging!
### Basic Logging
```kotlin
// Create a log sink
valsink=ConsoleLogSink(LogLevel.DEBUG)
// Create a logger
vallogger=DefaultLogger(sink)
// Log messages
logger.debug(tag="MyTag"){"Debug message"}
logger.info{"Info message"}
logger.warn{"Warning message"}
logger.error(throwable=exception){"Error message with exception"}
```
Note that the message parameter is a lambda that returns a String. This allows for lazy evaluation of the message, which can improve performance when the log level is set to filter out certain messages.
### Composite Logging (Multiple Sinks)
If you want to send logs to multiple destinations, use the CompositeLogSink:
```kotlin
// Create log sinks
valconsoleSink=ConsoleLogSink(LogLevel.INFO)
valotherSink=YourCustomLogSink(LogLevel.DEBUG)
// Create a composite sink
valcompositeSink=CompositeLogSink(
level=LogLevel.DEBUG,
sinks=listOf(
consoleSink,
otherSink
)
)
// Create a logger
vallogger=DefaultLogger(compositeSink)
// Log messages (will go to both sinks if level is appropriate)
logger.debug{"This goes only to otherSink if its level is DEBUG or lower"}
logger.info{"This goes to both sinks if their levels are INFO or lower"}
```
## Creating Custom Log Sinks
You can create your own log sink by implementing the LogSink interface:
```kotlin
classMyCustomLogSink(
overridevallevel:LogLevel,
// Add any other parameters you need
):LogSink{
overridefunlog(event:LogEvent){
// Implement your custom logging logic here
// For example, send logs to a remote server, write to a database, etc.