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

Do not log exception when failure (non-0) exit value is expected #116

Open
vorburger opened this issue May 13, 2023 · 0 comments
Open

Do not log exception when failure (non-0) exit value is expected #116

vorburger opened this issue May 13, 2023 · 0 comments
Assignees
Labels

Comments

@vorburger
Copy link
Owner

As a follow-up to the work in #108, and purely for "logging cosmetics" (without further functional/concurrency changes), it would be nice if e.g. when used for https://docs.enola.dev/use/execmd/ it would not log this confusing internal exception anymore in cases where this is actually completely expected, when a client of the library set the new SuccessExitValueChecker introduced in #115:

./enola execmd -i /home/vorburger/git/github.com/vorburger/enola/docs/use/help/index.md ...
2023-05-13 15:37:35 INFO ch.vorburger.exec.ManagedProcess startPreparation Starting Program [/usr/bin/env, bash, -c, cd .././.././.. && ./enola] (in working directory /home/vorburger/git/github.com/vorburger/enola/docs/use/help)
2023-05-13 15:37:35 INFO ch.vorburger.exec.ManagedProcess waitForExitMaxMs Thread is now going to wait max. 7000ms for process to terminate itself: Program [/usr/bin/env, bash, -c, cd .././.././.. && ./enola] (in working directory /home/vorburger/git/github.com/vorburger/enola/docs/use/help)
2023-05-13 15:37:36 SEVERE ch.vorburger.exec.SLF4jLogOutputStream processLine env: Missing required subcommand
2023-05-13 15:37:36 SEVERE ch.vorburger.exec.SLF4jLogOutputStream processLine env: Usage: enola [-hVv] COMMAND
2023-05-13 15:37:36 SEVERE ch.vorburger.exec.SLF4jLogOutputStream processLine env: https://enola.dev
2023-05-13 15:37:36 SEVERE ch.vorburger.exec.SLF4jLogOutputStream processLine env:   -h, --help      Show this help message and exit.
2023-05-13 15:37:36 SEVERE ch.vorburger.exec.SLF4jLogOutputStream processLine env:   -v, --verbose   Specify multiple -v options to increase verbosity. For
2023-05-13 15:37:36 SEVERE ch.vorburger.exec.SLF4jLogOutputStream processLine env:                     example, `-v -v -v` or `-vvv`
2023-05-13 15:37:36 SEVERE ch.vorburger.exec.SLF4jLogOutputStream processLine env:   -V, --version   Print version information and exit.
2023-05-13 15:37:36 SEVERE ch.vorburger.exec.SLF4jLogOutputStream processLine env: Commands:
2023-05-13 15:37:36 SEVERE ch.vorburger.exec.SLF4jLogOutputStream processLine env:   help                 Display help information about the specified command.
2023-05-13 15:37:36 SEVERE ch.vorburger.exec.SLF4jLogOutputStream processLine env:   generate-completion  Generate bash/zsh completion script for enola.
2023-05-13 15:37:36 SEVERE ch.vorburger.exec.SLF4jLogOutputStream processLine env:   docgen               Generate Markdown Documentation
2023-05-13 15:37:36 SEVERE ch.vorburger.exec.SLF4jLogOutputStream processLine env:   list-kinds           List known Entity Kinds
2023-05-13 15:37:36 SEVERE ch.vorburger.exec.SLF4jLogOutputStream processLine env:   list                 List Entities
2023-05-13 15:37:36 SEVERE ch.vorburger.exec.SLF4jLogOutputStream processLine env:   get                  Get Entity
2023-05-13 15:37:36 SEVERE ch.vorburger.exec.SLF4jLogOutputStream processLine env:   rosetta              Transform YAML <=> JSON <=> TextProto
2023-05-13 15:37:36 SEVERE ch.vorburger.exec.SLF4jLogOutputStream processLine env:   server               Start HTTP Server
2023-05-13 15:37:36 SEVERE ch.vorburger.exec.SLF4jLogOutputStream processLine env:   execmd               Execute Commands in Markdown
2023-05-13 15:37:36 SEVERE ch.vorburger.exec.LoggingExecuteResultHandler onProcessFailed Program [/usr/bin/env, bash, -c, cd .././.././.. && ./enola] (in working directory /home/vorburger/git/github.com/vorburger/enola/docs/use/help) failed unexpectedly
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
        at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404)
        at org.apache.commons.exec.DefaultExecutor.access$200(DefaultExecutor.java:48)
        at org.apache.commons.exec.DefaultExecutor$1.run(DefaultExecutor.java:200)
        at java.base/java.lang.Thread.run(Thread.java:829)

2023-05-13 15:37:36 SEVERE ch.vorburger.exec.ManagedProcess checkResult Program [/usr/bin/env, bash, -c, cd .././.././.. && ./enola] (in working directory /home/vorburger/git/github.com/vorburger/enola/docs/use/help) failed

Noe that above there are technically 2 separate log messages to look into surpressing here - both SEVERE, one from the LoggingExecuteResultHandler and the other one from the ManagedProcess.

This change is not really relevant e.g. for MariaDB4j (because it expectes the DB binaries it launches to always return 0), but only e.g. for Enola (because it supports exec with expected non-zero exit value in Executable Markdown).

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

No branches or pull requests

1 participant