Skip to content

Commit be449bb

Browse files
committed
DEVEX-671 Redirect FS logging to Log4j instead of SLF4J
1 parent ac065d2 commit be449bb

File tree

17 files changed

+110
-86
lines changed

17 files changed

+110
-86
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ local.properties
114114
fs-cli.log
115115
/build
116116
/**/build
117+
buildSrc/.kotlin
117118

118119
# ignore data.json to avoid release problems
119120
/data.json

RELEASENOTES.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Release notes
22

3+
## Version 4.8.5
4+
5+
* updated Gradle to 8.13
6+
* fixed logging with newer FirstSpirit versions
7+
8+
## Version 4.8.3
9+
10+
* provide more context for script parsing errors
11+
312
## Version 4.8.1
413

514
* fixed log level configuration

build.gradle.kts

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ var firstSpiritVersion = "5.2.231105"
3434

3535
plugins {
3636
application
37-
id("com.github.johnrengelman.shadow") version("7.0.0")
38-
id("org.ajoberstar.grgit") version("5.0.0")
37+
id("com.gradleup.shadow") version("8.3.6")
38+
id("org.ajoberstar.grgit") version("5.3.0")
3939
`maven-publish`
4040
id("com.github.breadmoirai.github-release") version("2.5.2")
41-
id("net.researchgate.release") version("3.0.2")
41+
id("net.researchgate.release") version("3.1.0")
4242
idea
4343
}
4444

@@ -47,7 +47,7 @@ plugins {
4747
///////////////////////////////////////////////////////
4848

4949
tasks.wrapper {
50-
gradleVersion = "8.7"
50+
gradleVersion = "8.13"
5151
distributionType = Wrapper.DistributionType.ALL
5252
}
5353

@@ -205,9 +205,11 @@ subprojects {
205205
compileOnly(group = "de.espirit.firstspirit", name = "fs-isolated-runtime", version = firstSpiritVersion)
206206
implementation(rootProject.libs.slf4j.api)
207207

208-
testRuntimeOnly(rootProject.testlibs.junit.jupiter.engine)
209-
testImplementation(rootProject.testlibs.junit.jupiter.api)
210-
testImplementation(rootProject.testlibs.junit.jupiter.params)
208+
testImplementation(platform("org.junit:junit-bom:5.12.1"))
209+
testImplementation(group = "org.junit.jupiter", name = "junit-jupiter")
210+
testImplementation(group = "org.junit.jupiter", name = "junit-jupiter-params")
211+
testRuntimeOnly(group = "org.junit.jupiter", name = "junit-jupiter-engine")
212+
testRuntimeOnly(group = "org.junit.platform", name = "junit-platform-launcher")
211213
testImplementation(rootProject.libs.hamcrest)
212214
testImplementation(rootProject.testlibs.mockito)
213215
testImplementation(rootProject.testlibs.assertj)
@@ -302,7 +304,7 @@ fun getJsonSchemas(project : Project) : List<File> {
302304
return files
303305
}
304306

305-
val createDocumentationJson by tasks.creating(JavaExec::class) {
307+
val createDocumentationJson by tasks.registering(JavaExec::class) {
306308
dependsOn(tasks.classes, "writeArtifactInfo")
307309
group = "documentation"
308310
description = "Run the main class with JavaExecTask"
@@ -311,7 +313,7 @@ val createDocumentationJson by tasks.creating(JavaExec::class) {
311313
args = listOf("--file", "${project(":fsdevtools-docs").projectDir}/build/assets/data.json")
312314
}
313315

314-
val writeArtifactInfo: Task by tasks.creating {
316+
val writeArtifactInfo by tasks.registering {
315317
group = "documentation"
316318
doLast {
317319
val branchName = grgit.branch.current().name
@@ -341,7 +343,7 @@ tokens.setProperty("javaVersion", javaVersion.toString())
341343
// assembles the tar.gz file
342344
///////////////////////////////////////////////////////
343345

344-
val assembleTarGz by tasks.creating(Tar::class) {
346+
val assembleTarGz by tasks.registering(Tar::class) {
345347
dependsOn(tasks.shadowJar, "fsdevtools-docs:buildVueApp")
346348

347349
group = "build"
@@ -363,13 +365,13 @@ val assembleTarGz by tasks.creating(Tar::class) {
363365
// copy fs-cli.sh with execution rights & lf
364366
from("${project.projectDir}/archive/bin/fs-cli.sh") {
365367
into("fs-cli/bin")
366-
fileMode = "755".toInt(8)
368+
filePermissions { unix("rwxr-xr-x") }
367369
filter<FixCrLfFilter>("eol" to FixCrLfFilter.CrLf.newInstance("lf"))
368370
}
369371
// copy fs-cli.cmd with execution rights & crlf
370372
from("${project.projectDir}/archive/bin/fs-cli.cmd") {
371373
into("fs-cli/bin")
372-
fileMode = "755".toInt(8)
374+
filePermissions { unix("rwxr-xr-x") }
373375
filter<FixCrLfFilter>("eol" to FixCrLfFilter.CrLf.newInstance("crlf"))
374376
}
375377
// copy fat jar
@@ -390,7 +392,7 @@ val assembleTarGz by tasks.creating(Tar::class) {
390392
// assembles the zip file
391393
///////////////////////////////////////////////////////
392394

393-
val assembleZip by tasks.creating(Zip::class) {
395+
val assembleZip by tasks.registering(Zip::class) {
394396
dependsOn(tasks.shadowJar, "fsdevtools-docs:buildVueApp")
395397

396398
group = "build"
@@ -411,13 +413,13 @@ val assembleZip by tasks.creating(Zip::class) {
411413
// copy fs-cli.sh with execution rights & lf
412414
from("${project.projectDir}/archive/bin/fs-cli.sh") {
413415
into("fs-cli/bin")
414-
fileMode = "755".toInt(8)
416+
filePermissions { unix("rwxr-xr-x") }
415417
filter<FixCrLfFilter>("eol" to FixCrLfFilter.CrLf.newInstance("lf"))
416418
}
417419
// copy fs-cli.cmd with execution rights & crlf
418420
from("${project.projectDir}/archive/bin/fs-cli.cmd") {
419421
into("fs-cli/bin")
420-
fileMode = "755".toInt(8)
422+
filePermissions { unix("rwxr-xr-x") }
421423
filter<FixCrLfFilter>("eol" to FixCrLfFilter.CrLf.newInstance("crlf"))
422424
}
423425
// copy fat jar
@@ -450,17 +452,18 @@ tasks.assemble {
450452
// setup the githubRelease plugin
451453
///////////////////////////////////////////////////////
452454

453-
val assets = mutableListOf(assembleTarGz.outputs.files, assembleZip.outputs.files)
455+
val assets = mutableListOf(assembleTarGz.get().outputs.files, assembleZip.get().outputs.files)
454456
for (project in project.project(":fsdevtools-scriptengines").subprojects) {
455457
val name = project.name
456-
val task = tasks.create(name, org.gradle.jvm.tasks.Jar::class)
457-
task.group = "script-engines"
458-
task.archiveFileName.set("fs-cli-scriptengine-${name}-${project.version}.jar")
459-
task.dependsOn("fsdevtools-scriptengines:${name}:build")
460-
task.dependsOn("fsdevtools-scriptengines:${name}:shadowJar")
461-
task.from(zipTree(project.layout.buildDirectory.file("shadowJAR/${name}-${project.version}.jar")))
462-
task.destinationDirectory.set(layout.buildDirectory.dir("distributions"))
463-
assets.add(task.outputs.files)
458+
val task = tasks.register(name, org.gradle.jvm.tasks.Jar::class) {
459+
group = "script-engines"
460+
archiveFileName.set("fs-cli-scriptengine-${name}-${project.version}.jar")
461+
dependsOn("fsdevtools-scriptengines:${name}:build")
462+
dependsOn("fsdevtools-scriptengines:${name}:shadowJar")
463+
from(zipTree(project.layout.buildDirectory.file("shadowJAR/${name}-${project.version}.jar")))
464+
destinationDirectory.set(layout.buildDirectory.dir("distributions"))
465+
}
466+
assets.add(task.get().outputs.files)
464467
tasks.build.get().dependsOn(task)
465468
tasks.githubRelease.get().dependsOn(task)
466469
}

fsdevtools-cli/src/main/java/com/espirit/moddev/cli/Main.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,23 @@
2424

2525
import org.slf4j.Logger;
2626
import org.slf4j.LoggerFactory;
27+
import org.slf4j.helpers.Reporter;
2728

2829
public class Main {
29-
private static final Logger LOGGER = LoggerFactory.getLogger(Main.class);
30+
private static final Logger LOGGER;
31+
32+
static {
33+
try {
34+
Class.forName("de.espirit.firstspirit.logging.ServiceProvider");
35+
// fs-isolated-runtime.jar contains SLF4J provider, select one explicitly
36+
System.setProperty(LoggerFactory.PROVIDER_PROPERTY_KEY, "org.apache.logging.slf4j.SLF4JServiceProvider");
37+
System.setProperty(Reporter.SLF4J_INTERNAL_VERBOSITY_KEY, "WARN");
38+
} catch (final ClassNotFoundException e) {
39+
// Nothing to do
40+
}
41+
42+
LOGGER = LoggerFactory.getLogger(Main.class);
43+
}
3044

3145
public static void main(final String[] args) {
3246
try {

fsdevtools-cli/src/main/java/com/espirit/moddev/cli/exception/FsLoggingBridge.java

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,152 +23,153 @@
2323
package com.espirit.moddev.cli.exception;
2424

2525
import de.espirit.common.base.Logger;
26+
import org.apache.logging.log4j.LogManager;
2627
import org.jetbrains.annotations.NotNull;
27-
import org.slf4j.LoggerFactory;
2828

2929
/**
30-
* The type FsLoggingBridge is the connection between FS Logging and the SLF4J API.
30+
* The type FsLoggingBridge is the connection between FS Logging and the Log4j API.
3131
*/
32+
@SuppressWarnings("NonExtendableApiUsage")
3233
public class FsLoggingBridge implements Logger {
3334

3435
@Override
3536
public boolean isTraceEnabled(@NotNull final Class<?> className) {
36-
return LoggerFactory.getLogger(className).isTraceEnabled();
37+
return LogManager.getLogger(className).isTraceEnabled();
3738
}
3839

3940
@Override
4041
public boolean isTraceEnabled(@NotNull final String className) {
41-
return LoggerFactory.getLogger(className).isTraceEnabled();
42+
return LogManager.getLogger(className).isTraceEnabled();
4243
}
4344

4445
@Override
4546
public void logTrace(@NotNull final String message, @NotNull final Class<?> className) {
46-
LoggerFactory.getLogger(className).trace(message);
47+
LogManager.getLogger(className).trace(message);
4748
}
4849

4950
@Override
5051
public void logTrace(@NotNull final String message, @NotNull final String className) {
51-
LoggerFactory.getLogger(className).trace(message);
52+
LogManager.getLogger(className).trace(message);
5253
}
5354

5455
@Override
5556
public void logTrace(@NotNull final String message, @NotNull final Throwable throwable, final Class<?> className) {
56-
LoggerFactory.getLogger(className).trace(message, throwable);
57+
LogManager.getLogger(className).trace(message, throwable);
5758
}
5859

5960
@Override
6061
public void logTrace(@NotNull final String message, @NotNull final Throwable throwable, @NotNull final String className) {
61-
LoggerFactory.getLogger(className).trace(message, throwable);
62+
LogManager.getLogger(className).trace(message, throwable);
6263
}
6364

6465
@Override
6566
public boolean isDebugEnabled(@NotNull final Class<?> className) {
66-
return LoggerFactory.getLogger(className).isDebugEnabled();
67+
return LogManager.getLogger(className).isDebugEnabled();
6768
}
6869

6970
@Override
7071
public boolean isDebugEnabled(@NotNull final String className) {
71-
return LoggerFactory.getLogger(className).isDebugEnabled();
72+
return LogManager.getLogger(className).isDebugEnabled();
7273
}
7374

7475
@Override
7576
public void logDebug(@NotNull final String message, @NotNull final Throwable throwable, @NotNull final Class<?> className) {
76-
LoggerFactory.getLogger(className).debug(message, throwable);
77+
LogManager.getLogger(className).debug(message, throwable);
7778
}
7879

7980
@Override
8081
public void logDebug(@NotNull final String message, @NotNull final Throwable throwable, @NotNull final String className) {
81-
LoggerFactory.getLogger(className).debug(message, throwable);
82+
LogManager.getLogger(className).debug(message, throwable);
8283
}
8384

8485
@Override
8586
public void logDebug(@NotNull final String message, @NotNull final Class<?> className) {
86-
LoggerFactory.getLogger(className).debug(message);
87+
LogManager.getLogger(className).debug(message);
8788
}
8889

8990
@Override
9091
public void logDebug(@NotNull final String message, @NotNull final String className) {
91-
LoggerFactory.getLogger(className).debug(message);
92+
LogManager.getLogger(className).debug(message);
9293
}
9394

9495
@Override
9596
public boolean isInfoEnabled(@NotNull final Class<?> className) {
96-
return LoggerFactory.getLogger(className).isInfoEnabled();
97+
return LogManager.getLogger(className).isInfoEnabled();
9798
}
9899

99100
@Override
100101
public boolean isInfoEnabled(@NotNull final String className) {
101-
return LoggerFactory.getLogger(className).isInfoEnabled();
102+
return LogManager.getLogger(className).isInfoEnabled();
102103
}
103104

104105
@Override
105106
public void logInfo(@NotNull final String message, @NotNull final Throwable throwable, @NotNull final Class<?> className) {
106-
LoggerFactory.getLogger(className).info(message, throwable);
107+
LogManager.getLogger(className).info(message, throwable);
107108
}
108109

109110
@Override
110111
public void logInfo(@NotNull final String message, @NotNull final Throwable throwable, @NotNull final String className) {
111-
LoggerFactory.getLogger(className).info(message, throwable);
112+
LogManager.getLogger(className).info(message, throwable);
112113
}
113114

114115
@Override
115116
public void logInfo(@NotNull final String message, @NotNull final Class<?> className) {
116-
LoggerFactory.getLogger(className).info(message);
117+
LogManager.getLogger(className).info(message);
117118
}
118119

119120
@Override
120121
public void logInfo(@NotNull final String message, @NotNull final String className) {
121-
LoggerFactory.getLogger(className).info(message);
122+
LogManager.getLogger(className).info(message);
122123
}
123124

124125
@Override
125126
public boolean isWarnEnabled(@NotNull final Class<?> className) {
126-
return LoggerFactory.getLogger(className).isWarnEnabled();
127+
return LogManager.getLogger(className).isWarnEnabled();
127128
}
128129

129130
@Override
130131
public boolean isWarnEnabled(@NotNull final String className) {
131-
return LoggerFactory.getLogger(className).isWarnEnabled();
132+
return LogManager.getLogger(className).isWarnEnabled();
132133
}
133134

134135
@Override
135136
public void logWarning(@NotNull final String message, @NotNull final Throwable throwable, @NotNull final Class<?> className) {
136-
LoggerFactory.getLogger(className).warn(message, throwable);
137+
LogManager.getLogger(className).warn(message, throwable);
137138
}
138139

139140
@Override
140141
public void logWarning(@NotNull final String message, @NotNull final Throwable throwable, @NotNull final String className) {
141-
LoggerFactory.getLogger(className).warn(message, throwable);
142+
LogManager.getLogger(className).warn(message, throwable);
142143
}
143144

144145
@Override
145146
public void logWarning(@NotNull final String message, @NotNull final Class<?> className) {
146-
LoggerFactory.getLogger(className).warn(message);
147+
LogManager.getLogger(className).warn(message);
147148
}
148149

149150
@Override
150151
public void logWarning(@NotNull final String message, @NotNull final String className) {
151-
LoggerFactory.getLogger(className).warn(message);
152+
LogManager.getLogger(className).warn(message);
152153
}
153154

154155
@Override
155156
public void logError(@NotNull final String message, @NotNull final Throwable throwable, @NotNull final Class<?> className) {
156-
LoggerFactory.getLogger(className).error(message, throwable);
157+
LogManager.getLogger(className).error(message, throwable);
157158
}
158159

159160
@Override
160161
public void logError(@NotNull final String message, @NotNull final Throwable throwable, @NotNull final String className) {
161-
LoggerFactory.getLogger(className).error(message, throwable);
162+
LogManager.getLogger(className).error(message, throwable);
162163
}
163164

164165
@Override
165166
public void logError(@NotNull final String message, @NotNull final Class<?> className) {
166-
LoggerFactory.getLogger(className).error(message);
167+
LogManager.getLogger(className).error(message);
167168
}
168169

169170
@Override
170171
public void logError(@NotNull final String message, @NotNull final String className) {
171-
LoggerFactory.getLogger(className).error(message);
172+
LogManager.getLogger(className).error(message);
172173
}
173174

174175
@Override

fsdevtools-commands/feature/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@
2323
dependencies {
2424
implementation(project(":fsdevtools-cli-api"))
2525
implementation(project(":fsdevtools-common"))
26-
testImplementation(libs.log4j.slf4j)
26+
testRuntimeOnly(libs.log4j.slf4j)
2727
}

fsdevtools-commands/server/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ dependencies {
2424
implementation(project(":fsdevtools-cli-api"))
2525
implementation(project(":fsdevtools-common"))
2626
implementation(libs.log4j.core)
27-
testImplementation(libs.log4j.slf4j)
27+
testRuntimeOnly(libs.log4j.slf4j)
2828
}

fsdevtools-common/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ dependencies {
3333
api(libs.jackson.databind)
3434

3535
testImplementation(libs.log4j.core)
36-
testImplementation(libs.log4j.slf4j)
36+
testRuntimeOnly(libs.log4j.slf4j)
3737
}

0 commit comments

Comments
 (0)