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

Output contains ansi sequences when redirected to a file #1204

Closed
gnodet opened this issue Nov 20, 2024 · 4 comments
Closed

Output contains ansi sequences when redirected to a file #1204

gnodet opened this issue Nov 20, 2024 · 4 comments
Milestone

Comments

@gnodet
Copy link
Contributor

gnodet commented Nov 20, 2024

mvnd install > foo.log should not print ansi sequences unless explicitely forced.

@gnodet gnodet added this to the 2.0.0-beta-2 milestone Nov 20, 2024
@gnodet
Copy link
Contributor Author

gnodet commented Nov 20, 2024

The description is not correct. The actual problem is that the daemon is given an argument -Dstyle.color=never when stdout is redirected (or a log file is provided, or batch mode) else -Dstyle.color=always. However, the daemon does not act upon this property the second time it is invoked.

The log of the daemon the second time looks like the following, where -Dstyle.color=never is correctly sent to the daemon, but ansi sequences are sent nevertheless.

23:41:09.889 I Request received: BuildRequest{args=[foo, -Dmaven.multiModuleProjectDirectory=/Users/gnodet/work/git/mvnd, -Dstyle.color=never, -T, 0.5C, -b, smart, -Dmvnd.terminalWidth=157], workingDir='/Users/gnodet/work/git/mvnd', projectDir='/Users/gnodet/work/git/mvnd', env='{HOMEBREW_PREFIX=/opt/homebrew, PATH=/Users/gnodet/.jbang/bin:/Users/gnodet/bin:/Users/gnodet/.sdkman/candidates/sbt/current/bin:/Users/gnodet/.sdkman/candidates/mvnd/current/bin:/Users/gnodet/.sdkman/candidates/maven/current/bin:/Users/gnodet/.sdkman/candidates/java/22-graal/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/munki:/Users/gnodet/.local/bin:/opt/homebrew/bin:/Users/gnodet/.local/bin, LOGNAME=gnodet, TERM=xterm-256color, LS_COLORS=di=1;36:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43, __CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0, XPC_FLAGS=0x0, TERM_PROGRAM_VERSION=455, LC_CTYPE=UTF-8, JABBA_HOME=/Users/gnodet/.jabba, TERM_PROGRAM=Apple_Terminal, JAVA_HOME=/Users/gnodet/.sdkman/candidates/java/22-graal, LESS=-R, LSCOLORS=Gxfxcxdxbxegedabagacad, SBT_HOME=/Users/gnodet/.sdkman/candidates/sbt/current, MAVEN_HOME=/Users/gnodet/.sdkman/candidates/maven/current, SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.b22MdySIgx/Listeners, ASF_LOGIN=gnodet, SDKMAN_DIR=/Users/gnodet/.sdkman, OLDPWD=/Users/gnodet/work/git/maven, SDKMAN_CANDIDATES_DIR=/Users/gnodet/.sdkman/candidates, XPC_SERVICE_NAME=0, PAGER=less, USER=gnodet, SDKMAN_PLATFORM=darwinarm64, HOMEBREW_CELLAR=/opt/homebrew/Cellar, MAVEN_CENTRAL=http://old-broken-macbook-pro.local:8082/artifactory/maven-remote/, MAVEN_OPTS=-DtrimStackTrace=false, PWD=/Users/gnodet/work/git/mvnd, _=/Users/gnodet/.sdkman/candidates/mvnd/current/bin/mvnd}'}
23:41:09.889 I Updating state to: Busy
23:41:09.890 I Executing request
23:41:09.938 I Dispatch message: BuildLogMessage{payload='[�[34;1mINFO�[0m] Processing build on daemon f3a2f665'}
23:41:09.939 I Dispatch message: BuildLogMessage{payload='[�[34;1mINFO�[0m] Daemon status dump:'}

@gnodet
Copy link
Contributor Author

gnodet commented Nov 21, 2024

All log statements do not contain ansi sequences, only the INFO, DEBUG parts, so I suspect that the cached values are not reset:
https://github.com/apache/maven/blob/master/impl/maven-logging/src/main/java/org/apache/maven/slf4j/MavenSimpleLogger.java#L55-L59
The loggers need to be all reset when a new build is started.
This may be similar to #1203

@gnodet
Copy link
Contributor Author

gnodet commented Nov 22, 2024

Still now working completely
image

@gnodet
Copy link
Contributor Author

gnodet commented Nov 22, 2024

This issue is fixed by #1189, in particular 9c7eb57

gnodet added a commit to gnodet/mvnd that referenced this issue Nov 25, 2024
gnodet added a commit to gnodet/mvnd that referenced this issue Nov 26, 2024
gnodet added a commit that referenced this issue Nov 26, 2024
@gnodet gnodet closed this as completed Dec 11, 2024
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

No branches or pull requests

1 participant