Kermit icon indicating copy to clipboard operation
Kermit copied to clipboard

Expose formatter to public or protected in CommonWriter

Open c0nstexpr opened this issue 2 years ago • 4 comments

https://github.com/touchlab/Kermit/blob/8e20fa506771c5078b55c0a32ef93e2889aba10e/kermit-core/src/commonMain/kotlin/co/touchlab/kermit/CommonWriter.kt#L19 At now CommonWriter's formatter is private, which make it impossible to use custom formatter when inheriting writer. See below

class MyWriter() : CommonWriter(MyFormatter()) {
    override fun log(severity: Severity, message: String, tag: String, throwable: Throwable?) =
        // Cannot access 'messageStringFormatter': it is invisible (private in a supertype)
        Mylog.log(messageStringFormatter.formatMessage(severity, Tag(tag), Message(message)))
}

c0nstexpr avatar Jul 25 '23 03:07 c0nstexpr

It's possible to customize Message Formatting. Did you check out this docs? https://kermit.touchlab.co/docs/configuration/MESSAGE_FORMATTING

findjigar avatar Sep 20 '23 17:09 findjigar

It's possible to customize Message Formatting. Did you check out this docs? https://kermit.touchlab.co/docs/configuration/MESSAGE_FORMATTING

Yes, I know the current way to customize log writer. And I also successfully implement my own writer. But if we implement a class to inherit CommonWriter, providing customization by overriding base log method seems to be pointless. Because the inheritor cannot access the formatter.

c0nstexpr avatar Sep 21 '23 01:09 c0nstexpr