Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import jakarta.inject.Singleton;
import org.grails.forge.application.ApplicationType;
import org.grails.forge.application.OperatingSystem;
import org.grails.forge.application.generator.GeneratorContext;
import org.grails.forge.build.dependencies.Dependency;
import org.grails.forge.feature.DefaultFeature;
Expand Down Expand Up @@ -61,17 +60,10 @@ public boolean shouldApply(ApplicationType applicationType, Options options, Set

@Override
public void apply(GeneratorContext generatorContext) {
OperatingSystem operatingSystem = generatorContext.getOperatingSystem();
boolean jansi = false;

if (operatingSystem != OperatingSystem.WINDOWS) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This breaks color logging on other OSs. I don't agree with this solution.

jansi = true;
}

String projectName = generatorContext.getProject().getName();
String packageName = generatorContext.getProject().getPackageName();

generatorContext.addTemplate("loggingConfig", new RockerTemplate("grails-app/conf/logback-spring.xml", logback.template(projectName, packageName, jansi)));
generatorContext.addTemplate("loggingConfig", new RockerTemplate("grails-app/conf/logback-spring.xml", logback.template(projectName, packageName)));
generatorContext.addDependency(Dependency.builder()
.groupId("org.apache.grails")
.artifactId("grails-logging")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ specific language governing permissions and limitations
under the License.
*@

@args (String projectName, String packageName, boolean jansi)
@args (String projectName, String packageName)

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>

<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<withJansi>@jansi</withJansi>
<withJansi>false</withJansi>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>${CONSOLE_LOG_THRESHOLD}</level>
</filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,18 @@ class LogbackSpec extends ApplicationContextSpec implements CommandOutputFixture
where:
applicationType << ApplicationType.values().toList()
}

@Unroll
void "test logback-spring.xml disables Jansi for #applicationType application"() {
when:
def output = generate(applicationType, new Options(DevelopmentReloading.DEVTOOLS))

then: "Jansi is disabled so its global System.out replacement does not break console logging after a Spring Boot DevTools restart (issue #15663)"
def logback = output.get("grails-app/conf/logback-spring.xml")
logback.contains("<withJansi>false</withJansi>")
!logback.contains("<withJansi>true</withJansi>")

where:
applicationType << ApplicationType.values().toList()
}
}
Loading