-
Notifications
You must be signed in to change notification settings - Fork 323
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
Fix Logger's name in stdlib #11519
Fix Logger's name in stdlib #11519
Conversation
Somehow SLF4J is able to recognize correctly the provided Logger's name and print it to the user. Java's Logger is not. In addition, we setup SLF4J's configuration, meaning that log-levels are correctly respected. For a simple project: ``` from Standard.Base import all from Standard.Base.Logging import all type Foo main = IO.println "Hello World!" Foo.log_message level=..Warning "I should warn you about something..." Foo.log_message level=..Info "Should be seen? By default we only show up-to warnings level" Foo.log_message level=..Severe "Something went really bad!" ``` This change demonstrates the fix. Before: ``` > enso --run simple-logging.enso Hello World! Nov 08, 2024 6:08:07 PM com.oracle.truffle.host.HostMethodDesc$SingleMethod$MHBase invokeHandle WARNING: I should warn you about something... Nov 08, 2024 6:08:07 PM com.oracle.truffle.host.HostMethodDesc$SingleMethod$MHBase invokeHandle INFO: Should be seen? By default we only show up-to warnings level Nov 08, 2024 6:08:07 PM com.oracle.truffle.host.HostMethodDesc$SingleMethod$MHBase invokeHandle SEVERE: Something went really bad! Foo ``` After: ``` > enso --run simple-logging.enso Hello World! [WARN] [2024-11-08T18:03:37+01:00] [simple-logging.Foo] I should warn you about something... [ERROR] [2024-11-08T18:03:37+01:00] [simple-logging.Foo] Something went really bad! Foo ```
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.
Thanks for resolving this! 🎉
I'm wondering if there's some reasonable way to test this? But I assume we don't have utils to intercept the logs from within Enso tests? Perhaps we could write a JUnit test in |
Co-authored-by: Radosław Waśko <radoslaw.wasko@enso.org>
I will think about it. |
As a bonus, stdlib logger respects log levels specified by the user:
|
Added `getEvents` member to `MemoryAppender` so that it is possible to retrieve individual log messages from tests and test their presence. Required opening up to some modules to retrieve internals of loggers.
Added. |
Pull Request Description
Somehow SLF4J is able to recognize correctly the provided Logger's name and print it to the user. Java's Logger is
not.
In addition, we setup SLF4J's configuration, meaning that log-levels are correctly respected.
For a simple project:
This change demonstrates the fix.
Before:
After:
Important Notes
Closes #11262.
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
TypeScript,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
or the Snowflake database integration, a run of the Extra Tests has been scheduled.