-
-
Notifications
You must be signed in to change notification settings - Fork 124
Issue #499 - improve Kotlin/JS logger #500
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
base: master
Are you sure you want to change the base?
Conversation
The problem with JS IIRC was that there is nodejs and browser that works completely different in the sense of obtaining logger name (maybe there was another use case I don't remember right now). So the question is how do we test it to make sure we improved both cases. Also if you can provide more details on the change it will be helpful to review. |
I am referring: #279 (comment) |
Every use case is covered by test for both JS and WASM. Please, have a look at the val topLevelNamedLogger = KotlinLogging.logger("topLevelNamedLogger")
val topLevelLambdaLogger = KotlinLogging.logger {}
class MyClass {
val classNamedLogger = KotlinLogging.logger("MyClass")
val classLambdaLogger = KotlinLogging.logger {}
// check with non default "Companion" name also
companion object MyCompanion {
val companionNamedLogger = KotlinLogging.logger("MyClassCompanion")
val companionLambdaLogger = KotlinLogging.logger {}
}
} You may run these tests with current (master) implementation and find out the tests failure.
Logger name for both JS and WASM is derived via stack trace analysis to cover all use cases. Currently this is the only way to properly obtain class name for all use cases. Analysis looks like:
Also you can find description here #499 |
logger.info { "info msg" } | ||
assertEquals("INFO: [SimpleJsTest] info msg", appender.lastMessage) | ||
assertEquals("INFO: [${logger.name}] info msg", appender.lastMessage) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you change this to an explicit string param with logger name, so it will be clear what was the name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's checking via checkLoggerName(logger: KLogger, expected: String)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oshai Hi, could we move this PR forward?
I think the PR is too big at the moment. |
Do you have any suggestions on how to make it smaller? I couldn't find any obvious options myself. Most of the code lines are tests.
As for the breaking changes, I believe it should be acceptable, since users would need to update the workaround syntax private val logger by KotlinLogging.logger() to the idiomatic version private val logger = KotlinLogging.logger {}
As mentioned earlier, both the browser and nodejs use cases are covered by the tests. If you don't mind to point out any parts of the code that aren't covered by tests, I’d really appreciate it. |
Closes #499