-
-
Notifications
You must be signed in to change notification settings - Fork 184
refactor: Separated JDK management code into its own module #1874
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
Conversation
afc114d to
f57b1c6
Compare
8c7ba7e to
4489268
Compare
2d66e04 to
21e1e5a
Compare
260870f to
0f35aa5
Compare
e0639c0 to
f5e2bb3
Compare
1d133d2 to
43b8906
Compare
|
small thing: how come the package is called |
| * This JUL Formatter is used to format JUL log messages in such a way that they | ||
| * look similar to JBang log messages. | ||
| */ | ||
| public class JBangFormatter extends Formatter { |
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.
hmm - originally I explicitly kept "ux output" separate from "logging output" ...is there a reason why we want to redirect all output to JUL ?
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.
Well, you might not want all of the logging output to be confused with UX output, I can understand that.
But there are two things that come to mind:
- our output mechanism sure does look like logging (having levels like warn, inifo, error, debug, etc)
- to make the new module really independent from JBang I needed a way to generate output that didn't use JBang's system and I didn't want to introduce some new interface
So that's why I decided to switch the module's output to use plain logging but then the output would look different from before, so that's why I decided to capture the logging output and make it look like JBang output.
Now, I thought it would be nice to do the same for anything that could be outputting logging info, but that's just something I decided in the moment and we could easily change that to only work for the module and nothing else.
| @@ -0,0 +1,4 @@ | |||
| handlers=java.util.logging.ConsoleHandler | |||
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.
why do we need this now? (not against it - just want to understand the rationale)
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 just to make any logging appear as if it comes directly from JBang (with our normal "[jbang]" prefix for every line), which was needed to make the logging output from the new module appear exactly the same as it did before.
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.
ok but:
a) what makes it end up in stderr not stdout?
b) doesn't this meddling with jul logging make it harder to embed?
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.
a) what do you mean? all JBang messages go to stderr, right? (at least any of the xxxMsg() methods, which is what the JUL logging replaces here)
b) also not sure what you mean here. Using JUL logging is pretty normal, isn't it? You could use it just fine even with logging completely disabled. There's no essential output being generated using JUL.
Historical reasons, because that was the tool is called that I want to use this module for. But it can of course be anything we want. |
43b8906 to
756ac41
Compare
efdcb7a to
095ae63
Compare
|
Yay, all checks green! I've marked the PR as final now that devkitman has been published and all the tests pass. |
build.gradle
Outdated
| implementation 'com.offbytwo:docopt:0.6.0.20150202' | ||
| implementation 'dev.jbang:devkitman:0.1.2' | ||
|
|
||
| // implementation 'com.offbytwo:docopt:0.6.0.20150202' |
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.
This probably shouldn't be here, but it seemed unused to I commented it out and it slipped into the PR. If you want I can remove it from the PR.
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.
lol - thats a ancient leftover from very early jbang...never needed. lets just nuke it.
| shadowJar { | ||
| minimize() { | ||
| //exclude(dependency('org.slf4j:slf4j-api:.*')) | ||
| exclude(dependency('dev.jbang:devkitman:.*')) |
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.
devkitman uses services so this is needed or classes will be missing.
c1b7b49 to
cc0c494
Compare
| @BeforeAll | ||
| static void init() throws URISyntaxException, IOException { | ||
| try { | ||
| // The default ConsoleHandler for logging doesn't like us changing |
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.
yeah so all this is why i refrained from using JUL for jbang output. why is this in the test class? shouldn't it be in main code path too?
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.
But in this module JUL is only used for logging, there is no essential output being generated with it. It's a library, it shouldn't do any essential output by itself, it only returns information which the caller can then decide to output or not. The logging is really only used for logging.
Thing is we do have tests that specifically check for certain log lines, we shouldn't really be doing that but I didn't want to change the tests so I added this code to make sure that the output between monolithic JBang and modular JBang would remain 99.9% the same.
003435a to
1401ab1
Compare
This reverts commit edf06a1.
Fixes #1857