Colotok Docs Help

Provider

colotok has builtin provider. Provider is used for output log.

ConsoleProvider

ConsoleProvider write the log into console

.... .addProvider(ConsoleProvider{ level = LogLevel.DEBUG formatter = DetailTextFormatter colorize = true traceLevelColor = AnsiColor.WHITE debugLevelColor = AnsiColor.BLUE infoLevelColor = AnsiColor.GEEN warnLevelColor = AnsiColor.YELLOW errorLevelColor = AnsiColor.RED })

ConsoleProvider can colorize with ANSI-Color

FileProvider

FileProvider write the log into file.

If enableBuffer is true, FileProvider will buffering until buffer is full,
when buffer becomes full, write content into file and cleared the buffer.

val fileProvider: FileProvider .... .addProvider(FileProvider(Path.of("./test.log")){ level = LogLevel.TRACE formatter = DetailTextFormatter enableBuffer = true bufferSize = 2048 rotation = SizeBaseRotation(size = 8192) }.apply { fileProvider = this }

LogRotation

FileProvider can log-rotation.

SizeBaseRotation

this rotation will rotate when log size over passed [size].

rotation = SizeBaseRotation(size = 8192)

DateBaseRotation

this rotation will rotate when log file spent over [period]

rotation = DateBaseRotation(period = 7.days)

StreamProvider

StreamProvider write the log into stream

val streamProvider: StreamProvider .... .addProvider(StreamProvider{ enableBuffer = true bufferSize = 64.KiB() formatter = SimpleStructureFormatter outputStreamBuilder = { FileOutputStream("./stream-log", true) } }.apply { streamProvider = this })
Last modified: 12 March 2024