Skip to content

Commit

Permalink
chore: set logger.properties for test
Browse files Browse the repository at this point in the history
It allows developers to manipulate logging levels in precise easily.
- Add config/test/logger.properties
- Only logging on console when testing
- set system property j.u.l.config.file

Signed-off-by: Hiroshi Miura <[email protected]>
  • Loading branch information
miurahr committed Nov 2, 2024
1 parent 43f1250 commit ec5af02
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
12 changes: 10 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,9 @@ dependencies {
testImplementation(libs.bundles.xmlunit)

testImplementation(project(":language-modules"))
testImplementation(libs.languagetool.server)
testImplementation(libs.languagetool.server) {
exclude module: "logback-classic"
}
testRuntimeOnly(libs.slf4j.jdk14)

// JAXB codegen only
Expand Down Expand Up @@ -1587,6 +1589,7 @@ test {
if (project.hasProperty('headless')) {
systemProperty 'java.awt.headless', 'true'
}
systemProperty 'java.util.logging.config.file', "${rootDir}/config/test/logger.properties"
}

tasks.register('testIntegration', JavaExec) {
Expand All @@ -1599,6 +1602,7 @@ tasks.register('testIntegration', JavaExec) {
mainClass = 'org.omegat.core.data.TestTeamIntegration'
classpath = sourceSets.testIntegration.runtimeClasspath
systemProperties = System.properties
systemProperty 'java.util.logging.config.file', "${rootDir}/config/test/logger.properties"
}

tasks.register('testOnJava17', Test) {
Expand All @@ -1607,9 +1611,11 @@ tasks.register('testOnJava17', Test) {
languageVersion = JavaLanguageVersion.of(17)
vendor = JvmVendorSpec.ADOPTIUM
}
systemProperties = System.properties
if (project.hasProperty('headless')) {
systemProperty 'java.awt.headless', 'true'
}
systemProperty 'java.util.logging.config.file', "${rootDir}/config/test/logger.properties"
group = 'verification'
}

Expand All @@ -1619,9 +1625,11 @@ tasks.register('testOnJava21', Test) {
languageVersion = JavaLanguageVersion.of(21)
vendor = JvmVendorSpec.ADOPTIUM
}
systemProperties = System.properties
if (project.hasProperty('headless')) {
systemProperty 'java.awt.headless', 'true'
}
systemProperty 'java.util.logging.config.file', "${rootDir}/config/test/logger.properties"
group = 'verification'
}

Expand All @@ -1637,7 +1645,7 @@ tasks.register('testAcceptance', Test) {
testClassesDirs = sourceSets.testAcceptance.output.classesDirs
classpath = sourceSets.testAcceptance.runtimeClasspath
systemProperties = System.properties
shouldRunAfter(tasks.test)
systemProperty 'java.util.logging.config.file', "${rootDir}/config/test/logger.properties"
}

ext.mavenStyleVersion = version.replace('_', '-')
Expand Down
35 changes: 35 additions & 0 deletions config/test/logger.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
handlers = java.util.logging.ConsoleHandler

# Set the default logging level for the root logger
.level = INFO
org.omegat.level = ALL

# Set the default logging level
java.util.logging.ConsoleHandler.level = ALL
org.omegat.util.logging.OmegaTFileHandler.level = ALL

#org.omegat.util.logging.OmegaTLogFormatter.mask=$time: $level: $text $key
org.omegat.util.logging.OmegaTLogFormatter.mask=$time: $threadName [$level] $key $text
#org.omegat.util.logging.OmegaTLogFormatter.mask=$mark: $level: $text $key

org.omegat.util.logging.OmegaTLogFormatter.timeFormat=HH:mm:ss.SSS

java.util.logging.ConsoleHandler.formatter = org.omegat.util.logging.OmegaTLogFormatter

# precise control of log levels, please change when debug
org.omegat.core.data.level = INFO
org.omegat.core.threads.level = INFO
org.omegat.core.team2.impl.level = INFO
org.omegat.core.team2.level = INFO
org.omegat.gui.editor.history.level = INFO
org.omegat.gui.matches.level = INFO
org.omegat.util.gui.level = INFO
org.omegat.util.level = INFO

# Suppress warning from depndency jStyleParser
cz.vutbr.web.level = SEVERE
org.fit.net.level = SEVERE

# We can enable specific logging level for some classes
#org.omegat.core.data.SaveThread.level = FINEST
org.omegat.core.segmentation.level = FINEST

0 comments on commit ec5af02

Please sign in to comment.