Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose formatter to public or protected in CommonWriter #360

Open
c0nstexpr opened this issue Jul 25, 2023 · 2 comments
Open

Expose formatter to public or protected in CommonWriter #360

c0nstexpr opened this issue Jul 25, 2023 · 2 comments

Comments

@c0nstexpr
Copy link

c0nstexpr commented Jul 25, 2023

open class CommonWriter(private val messageStringFormatter: MessageStringFormatter = DefaultFormatter) : LogWriter() {

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)))
}
@findjigar
Copy link
Contributor

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

@c0nstexpr
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants