Official Plugin
Colotok provides several official plugins to extend its functionality for different use cases. This page describes each plugin, when to use it, and how to set it up.
colotok-coroutines
The colotok-coroutines
plugin provides coroutine support for Colotok, allowing you to log asynchronously in coroutine contexts.
Description: As a default, Colotok is not coroutines-friendly. This plugin adds async versions of all logging methods.
When to Use: Use this plugin when your application uses Kotlin coroutines and you want to:
Log asynchronously without blocking the current coroutine
Integrate logging with your coroutine-based application flow
Avoid blocking I/O operations during logging
Setup: Add the dependency to your project:
Usage: The plugin provides async versions of all standard logging methods:
Platform Support: This plugin is available for all platforms supported by Kotlin Multiplatform.
colotok-cloudwatch (JVM only)
The colotok-cloudwatch
plugin provides integration with Amazon CloudWatch Logs, allowing you to send logs directly to AWS CloudWatch.
Description: This plugin enables sending logs to AWS CloudWatch Logs service, with support for different credential providers and buffered logging.
When to Use: Use this plugin when:
Your application runs on AWS infrastructure
You want to centralize logs in CloudWatch
You need to monitor logs across multiple instances
You want to leverage CloudWatch's log analysis features
Setup: Add the dependency to your project:
Usage: Configure the CloudWatch provider with your AWS credentials and log group/stream information:
Buffering and Flushing: The CloudWatch provider buffers logs to improve performance. Logs are sent to CloudWatch when:
The buffer reaches the configured size (
logBufferSize
)You explicitly call
flush()
on the provider
Platform Support: This plugin is available for JVM platform only.
colotok-slf4j (JVM only)
The colotok-slf4j
plugin allows Colotok to be used as an SLF4J implementation.
Description: This plugin enables applications that use SLF4J for logging to use Colotok as the logging backend.
When to Use: Use this plugin when:
Your application or its dependencies use SLF4J for logging
You want to route SLF4J logs through Colotok
You need to integrate with existing code that uses SLF4J
Setup: Add the dependency to your project:
You'll also need to configure SLF4J to use Colotok as its implementation. This typically involves ensuring that the Colotok SLF4J binding is the only SLF4J implementation on the classpath.
Usage: Once configured, you can use SLF4J as normal, and the logs will be processed by Colotok:
Platform Support: This plugin is available for JVM platform only.
colotok-loki
The colotok-loki
plugin provides integration with Grafana Loki, allowing you to send logs directly to a Loki server.
Description: This plugin enables sending logs to a Grafana Loki server using its HTTP API, with support for buffering and authentication.
When to Use: Use this plugin when:
You use Grafana for visualization and monitoring
You want to centralize logs in Loki
You need advanced log querying capabilities
You want to create dashboards and alerts based on log data
Setup: Add the dependency to your project:
Usage: Configure the Loki provider with your Loki server information:
Buffering and Flushing: The Loki provider buffers logs to improve performance. Logs are sent to Loki when:
The buffer reaches the configured size (
bufferSize
)You explicitly call
flush()
on the provider
Platform Support: This plugin is available for all platforms supported by Kotlin Multiplatform.