Skip to content

Commit fd73ce2

Browse files
committed
make log level configurable
1 parent e986194 commit fd73ce2

File tree

7 files changed

+24
-11
lines changed

7 files changed

+24
-11
lines changed

dependencies.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ext {
1313
picocli: '4.6.1',
1414
rmf: '0.2.0-20240722205528',
1515
rxjava: '3.1.2',
16-
slf4j: '1.7.25',
16+
slf4j: '2.0.17',
1717
spock: '2.2-groovy-4.0',
1818
swaggerParser: '2.1.20',
1919
jsoup: '1.15.1',

tools/cli-application/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ dependencies {
9898
api 'org.eclipse.elk:org.eclipse.elk.alg.layered:0.8.1'
9999
api 'org.eclipse.elk:org.eclipse.elk.alg.mrtree:0.8.1'
100100

101+
api 'ch.qos.logback:logback-classic:1.5.10'
102+
101103
implementation orgkotlin.stdlib
102104
implementation google.guava
103105
implementation picocli.cli

tools/cli-application/src/main/kotlin/io/vrap/rmf/codegen/cli/GenerateSubcommand.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ import io.vrap.codegen.languages.typescript.joi.JoiBaseTypes
4343
import io.vrap.codegen.languages.typescript.joi.JoiModule
4444
import io.vrap.rmf.codegen.CodeGeneratorConfig
4545
import io.vrap.rmf.codegen.di.*
46-
import io.vrap.rmf.codegen.io.DataSink
4746
import io.vrap.rmf.codegen.io.FileDataSink
48-
import io.vrap.rmf.codegen.io.TemplateFile
4947
import io.vrap.rmf.codegen.toSeconds
5048
import io.vrap.rmf.codegen.types.VrapObjectType
5149
import io.vrap.rmf.codegen.types.VrapType

tools/cli-application/src/main/kotlin/io/vrap/rmf/codegen/cli/Utils.kt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package io.vrap.rmf.codegen.cli
22

3+
import io.vrap.rmf.codegen.io.ConsoleDataSink
34
import io.vrap.rmf.raml.model.RamlDiagnostic
45
import io.vrap.rmf.raml.model.RamlModelResult
56
import io.vrap.rmf.raml.model.modules.Api
67
import io.vrap.rmf.raml.validation.Violation
78
import org.eclipse.emf.common.util.Diagnostic
89
import org.eclipse.emf.common.util.URI
10+
import org.slf4j.LoggerFactory
911
import java.nio.file.Paths
1012
import kotlin.io.path.toPath
1113

@@ -151,36 +153,37 @@ class GithubRamlDiagnosticPrinter: RamlDiagnosticPrinter {
151153

152154
object InternalLogger {
153155

156+
private val LOGGER = LoggerFactory.getLogger(InternalLogger::class.java)
157+
154158
var logLevel = LogLevel.INFO
155159

156160
fun debug(message: String) {
157161
if (logLevel.level <= LogLevel.DEBUG.level) {
158-
println("$message")
162+
LOGGER.debug("$message")
159163
}
160164
}
161165

162166
fun info(message: String) {
163167
if (logLevel.level <= LogLevel.INFO.level) {
164-
println("$message")
168+
LOGGER.info("$message")
165169
}
166170
}
167171

168172
fun warn(message: Throwable) {
169173
if (logLevel.level <= LogLevel.WARN.level) {
170-
println("⚠️ $message")
174+
LOGGER.warn("⚠️ $message")
171175
}
172176
}
173177

174178
fun error(message: String) {
175179
if (logLevel.level <= LogLevel.ERROR.level) {
176-
println("🛑 $message")
180+
LOGGER.error("🛑 $message")
177181
}
178182
}
179183

180184
fun error(throwable: Throwable) {
181185
if (logLevel.level <= LogLevel.ERROR.level) {
182-
println("🛑 $throwable")
183-
186+
LOGGER.error("🛑 $throwable")
184187
}
185188
}
186189
}

tools/cli-application/src/main/kotlin/io/vrap/rmf/codegen/cli/VerifySubcommand.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,3 @@ class VerifySubcommand : Callable<Int> {
8484
}
8585

8686
}
87-
88-
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
slf4j.internal.verbosity=WARN
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<configuration>
2+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
3+
<encoder>
4+
<pattern>%msg%n</pattern>
5+
</encoder>
6+
</appender>
7+
<variable name="LOGLEVEL" value="${LOGLEVEL:-INFO}" />
8+
<root level="${LOGLEVEL}">
9+
<appender-ref ref="STDOUT" />
10+
</root>
11+
</configuration>

0 commit comments

Comments
 (0)