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

JBEAP-26480: add --debug option to CLI #553

Merged
merged 1 commit into from Feb 7, 2024

Conversation

michpetrov
Copy link
Contributor

Issue: JBEAP-26480

Feels like there should be better way to get a hold of the console handler but I haven't found any.

Copy link
Collaborator

@spyrkob spyrkob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use LogManager.getLogManager() to get loggers as well.

This doesn't work when using the prospero distribution (dist/build/target). Either the default logging configuration needs to include a console handler set to level OFF, or the code needs to add the console handler.

@michpetrov
Copy link
Contributor Author

Updated.

You can use LogManager.getLogManager() to get loggers as well.

Yeah, but my problem was that we could only access loggers this way. E.g. I cannot directly do getHandler("CONSOLE").setLevel(DEBUG) or getLogger("").addHandler("CONSOLE") because I cannot access handlers by name. The only solution seems to be accessing the whole configuration the way I did.

Btw, is the -Pdist build supposed to be creating a jar? I thought that's what I should run before I found out there is no Java code inside.

@spyrkob
Copy link
Collaborator

spyrkob commented Feb 6, 2024

Btw, is the -Pdist build supposed to be creating a jar? I thought that's what I should run before I found out there is no Java code inside.

No -Pdist builds feature packs and provisions the standalone feature pack to create a distribution of prospero.

@@ -105,6 +109,16 @@ public static CommandLine createCommandLine(CliConsole console, String[] args, A

commandLine.setParameterExceptionHandler(new UnknownCommandParameterExceptionHandler(rootParameterExceptionHandler, System.err));

final boolean isDebug = Arrays.stream(args).anyMatch(CliConstants.DEBUG::equals);
if (isDebug) {
LogContextConfiguration lcc = ((PropertyConfigurator) org.jboss.logmanager.Logger.getLogger("").getAttachment(Configurator.ATTACHMENT_KEY))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry one more nitpick - could you handle a case when the attachement cannot be case to PropertyConfigurator or is null? I think we should just print an error message, but continue the execution in that case, WDYT?

@michpetrov
Copy link
Contributor Author

Right, what I'm saying is that if I run -Pdist it generates 3 files - zip, tar.gz and jar.

I've added the check, as far as I can tell it will only fail if someone deletes the properties file. You want this ported to 1.1.x too?

@spyrkob
Copy link
Collaborator

spyrkob commented Feb 7, 2024

Right, what I'm saying is that if I run -Pdist it generates 3 files - zip, tar.gz and jar.

Ah sorry I misunderstood you. Yes the jar is empty, I'm not sure if it's possible to disable building it

You want this ported to 1.1.x too?

Yes please if you don't mind

@spyrkob
Copy link
Collaborator

spyrkob commented Feb 7, 2024

Thanks @michpetrov

@spyrkob spyrkob merged commit fc5e80b into wildfly-extras:main Feb 7, 2024
5 checks passed
@michpetrov michpetrov deleted the jbeap-26480 branch February 7, 2024 17:35
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

Successfully merging this pull request may close these issues.

None yet

2 participants