Provider
Colotok has built-in providers. A provider receives accepted log records and writes them to a destination.
Common Provider Configuration
Every provider config exposes the following options. The defaults below apply to the core built-in providers (ConsoleProvider, FileProvider, and StreamProvider); integration providers may choose different level and formatter defaults, as listed in the official plugin guide.
Property | Description | Default |
|---|---|---|
| Minimum log level for this provider |
|
| Formatter to use |
|
| How to collect metrics ( |
|
| Whether to log metrics as internal records ( |
|
ConsoleProvider
ConsoleProvider write the log into console
On Android, ConsoleProvider() does not write to Logcat with its default configuration. From your Android source set, provide the debug-mode decision explicitly when debug output is wanted:
|
|
| Output |
|---|---|---|---|
| any | any | disabled |
|
| any | enabled |
|
|
| enabled |
|
|
| disabled (default) |
Colotok does not infer debug builds from BuildConfig.DEBUG.
On JVM and Native targets, ConsoleProvider can colorize output with ANSI colors. The color properties are platform-specific; Android's ConsoleProvider writes to Logcat and does not expose these color properties.
FileProvider
FileProvider writes the log into a file asynchronously.
FileProvider accepts an Okio Path. Okio is exposed transitively by the colotok artifact; add a direct Okio dependency only when your own code uses Okio APIs.
FileProvider can rotate log files using rotation. A rotated file is renamed to application.log.1, application.log.2, and so on. When the path passed to FileProvider is an existing directory, the active file is application.log inside that directory.
SizeBaseRotation
This rotation runs after a write when the file size is greater than [size] bytes.
DateBaseRotation
This rotation runs after a write when the file's creation time (or, when unavailable, last modified time) is at least [period] old.
StreamProvider
StreamProvider write the log into stream
StreamProvider accepts an Okio Sink factory. Okio is exposed transitively by the colotok artifact; add a direct Okio dependency only when your own code uses Okio APIs.
AsyncProvider buffering
Provider.write() はnon-blockingのenqueue試行です。default SUSPEND policyでもcapacityを 待たず、channelが満杯なら既存のFIFO prefixを残してnewest recordをrejectします。 AsyncProvider.writeAsync()はcapacityが空くまでsuspendします。通常のProviderに対する coroutine *Async APIは、同じnon-blocking write() pathへdelegateします。
bufferSize は送信を試みる閾値で、有効範囲は 1..4096 です。送信失敗時は min(bufferSize * 4, 4096) 件まで既存レコードを保持します。上限到達後は、古い未送信レコードを残すため新しいレコードを破棄します。
送信先がバッチの一部だけを受理してから失敗した場合、保持したバッチの再送で重複が発生し得ます。リモート Provider は at-least-once delivery として扱い、受信側を重複許容にしてください。
自動 publish の失敗は記録され、後続の publish で再試行できます。明示的な flush() の失敗は呼び出し元へ伝播して Provider を failed 状態にし、その後の join() も同じ原因を通知します。
ログ呼び出し時に attributes と MDC は snapshot されます。その後に元の map を変更しても、非同期 formatter の出力は変化しません。