Provider
colotok has builtin provider. Provider is used for output log.
Common Provider Configuration
All providers support the following configuration options:
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. 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.
ConsoleProvider can colorize with ANSI-Color
FileProvider
FileProvider writes the log into a file asynchronously.
FileProvider can rotate log files using rotation.
SizeBaseRotation
this rotation will rotate when log size over passed [size].
DateBaseRotation
this rotation will rotate when log file spent over [period]
StreamProvider
StreamProvider write the log into stream
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 の出力は変化しません。