apache / maven-mvnd

Apache Maven Daemon
https://maven.apache.org/
Apache License 2.0
2.92k stars 212 forks source link

Output contains ansi sequences when redirected to a file #1204

Open gnodet opened 4 days ago

gnodet commented 4 days ago

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

gnodet commented 3 days ago

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='[INFO] Processing build on daemon f3a2f665'}
23:41:09.939 I Dispatch message: BuildLogMessage{payload='[INFO] Daemon status dump:'}
gnodet commented 3 days ago

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 commented 1 day ago

Still now working completely

image
gnodet commented 1 day ago

This issue is fixed by https://github.com/apache/maven-mvnd/pull/1189, in particular https://github.com/apache/maven-mvnd/pull/1189/commits/9c7eb578f430519d8e9e498e64fe3e346779ff99