Package-level declarations

Types

Link copied to clipboard
Link copied to clipboard
open class BaseLogger(val config: LoggerConfig)

Base class for public Logger API. Extend to implement your own logger API.

Link copied to clipboard
class ChunkedLogWriter(wrapped: LogWriter, maxMessageLength: Int, minMessageLength: Int) : LogWriter
Link copied to clipboard
open class CommonWriter(messageStringFormatter: MessageStringFormatter = DefaultFormatter) : LogWriter

Basic LogWriter. Statements are sent to println.

Link copied to clipboard
Link copied to clipboard

Single-line string with severity, tag, and message.

Link copied to clipboard
annotation class ExperimentalKermitApi
Link copied to clipboard
class LogcatWriter(messageStringFormatter: MessageStringFormatter = DefaultFormatter) : LogWriter
Link copied to clipboard
interface LoggerConfig

Config info for all Logger instances

Link copied to clipboard
abstract class LogWriter

Called by Logger to actually send log statements to specific targets. There are several implementations provided by Kermit, but you can supply your own for specific use cases.

Link copied to clipboard
value class Message(val message: String)
Link copied to clipboard
typealias MessageBlock = () -> String
Link copied to clipboard

Implement message format for log writer. Some platforms have native support for either severity or tags. A formatter should ignore those parameters for relevant platforms. For example, on Android both tag and severity are part of the logging API. However, in JavaScript, while severity is part of the API, tags are not.

Link copied to clipboard

Config that can be updated. The global Logger instance needs mutable state. Most logging use cases do not, however there are some situations that may. Mutable config is less performant because state needs to be thread safe, which means volatile in the jvm and atomic in native. Each log call must access mutable, cross-thread state.

Link copied to clipboard

Tags are a formal part of Android, but not other systems. This formatter omits them.

Link copied to clipboard
class NSLogWriter(messageStringFormatter: MessageStringFormatter = DefaultFormatter) : LogWriter

Legacy logger, using NSLog

Link copied to clipboard
open class OSLogWriter : LogWriter

Write log statements to darwin oslog.

Link copied to clipboard
Link copied to clipboard

Just logs the message.

Link copied to clipboard
data class StaticConfig(val minSeverity: Severity = DEFAULT_MIN_SEVERITY, val logWriterList: List<LogWriter> = listOf(CommonWriter())) : LoggerConfig

Immutable LoggerConfig. Access is thread safe because state is immutable. Use this is you are worried about logging performance.

Link copied to clipboard
class SystemWriter(messageStringFormatter: MessageStringFormatter = DefaultFormatter) : LogWriter
Link copied to clipboard
value class Tag(val tag: String)
Link copied to clipboard
open class XcodeSeverityWriter(messageStringFormatter: MessageStringFormatter = DefaultFormatter) : OSLogWriter

Development-focused LogWriter. Will write a colored emoji according to Severity, and write the Throwable stack trace to println rather than oslog, as oslog will cut off long strings.

Functions

Link copied to clipboard
fun LogWriter.chunked(maxMessageLength: Int = 4000, minMessageLength: Int = 3000): LogWriter
Link copied to clipboard
external fun consoleError(output: String)
Link copied to clipboard
external fun consoleInfo(output: String)
Link copied to clipboard
external fun consoleLog(output: String)
Link copied to clipboard
external fun consoleWarn(output: String)
Link copied to clipboard
fun loggerConfigInit(vararg logWriters: LogWriter, minSeverity: Severity = DEFAULT_MIN_SEVERITY): LoggerConfig

Factory function to create a StaticConfig

Link copied to clipboard
fun mutableLoggerConfigInit(vararg logWriters: LogWriter, minSeverity: Severity = DEFAULT_MIN_SEVERITY): MutableLoggerConfig
Link copied to clipboard
expect fun platformLogWriter(messageStringFormatter: MessageStringFormatter = DefaultFormatter): LogWriter

Factory function to return a default LogWriter for each platform. The LogWriter is targeted at local development. For production implementations, you may need to directly initialize your Logger config.

actual fun platformLogWriter(messageStringFormatter: MessageStringFormatter): LogWriter
actual fun platformLogWriter(messageStringFormatter: MessageStringFormatter): LogWriter
actual fun platformLogWriter(messageStringFormatter: MessageStringFormatter): LogWriter
actual fun platformLogWriter(messageStringFormatter: MessageStringFormatter): LogWriter