Skip to content

Disable large logs in tests for FastDoubleParser #1094

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 13, 2025
Merged
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 @@ -165,7 +165,7 @@ public class FastDoubleParser(private val parserOptions: ParserOptions? = null)
}
}.also {
if (it == null) {
logger.debug { "Could not parse '$this' as Double with NumberFormat with locale '$locale'." }
logger.trace { "Could not parse '$this' as Double with NumberFormat with locale '$locale'." }
}
}

Expand All @@ -185,7 +185,7 @@ public class FastDoubleParser(private val parserOptions: ParserOptions? = null)
try {
return parser.parseDouble(ba, offset, length)
} catch (e: Exception) {
logger.debug(e) {
logger.trace(e) {
"Failed to parse '${
ba.toString(charset)
}' from a ByteArray to Double with FastDoubleParser with locale '$locale'."
Expand All @@ -207,7 +207,7 @@ public class FastDoubleParser(private val parserOptions: ParserOptions? = null)
try {
return parser.parseDouble(cs)
} catch (e: Exception) {
logger.debug(e) {
logger.trace(e) {
"Failed to parse '$cs' from a CharSequence to Double with FastDoubleParser with locale '$locale'."
}
}
Expand All @@ -227,7 +227,7 @@ public class FastDoubleParser(private val parserOptions: ParserOptions? = null)
try {
return parser.parseDouble(ca, offset, length)
} catch (e: Exception) {
logger.debug(e) {
logger.trace(e) {
"Failed to parse '${
ca.joinToString("")
}' as from a CharArray to Double with FastDoubleParser with locale '$locale'."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,24 @@ import org.junit.Test
import java.text.NumberFormat
import java.util.Locale

// can be enabled for showing logs for these tests
private const val SHOW_LOGS = false

class FastDoubleParserTests {

private val logLevel = "org.slf4j.simpleLogger.log.${FastDoubleParser::class.qualifiedName}"
private var loggerBefore: String? = null

@Before
fun setLogger() {
if (!SHOW_LOGS) return
loggerBefore = System.getProperty(logLevel)
System.setProperty(logLevel, "debug")
System.setProperty(logLevel, "trace")
}

@After
fun restoreLogger() {
if (!SHOW_LOGS) return
if (loggerBefore != null) {
System.setProperty(logLevel, loggerBefore)
}
Expand Down
4 changes: 0 additions & 4 deletions core/src/test/resources/simplelogger.properties
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,3 @@ org.slf4j.simpleLogger.showLogName=true
# Set to true if you want the last component of the name to be included in output messages.
# Defaults to false.
#org.slf4j.simpleLogger.showShortLogName=false

# Disables FastDoubleParser debug logs by default in our tests
# Can be enabled by setting the system property programmatically
org.slf4j.simpleLogger.log.org.jetbrains.kotlinx.dataframe.impl.io.FastDoubleParser=warn
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ import java.util.zip.GZIPInputStream
import kotlin.reflect.KClass
import kotlin.reflect.typeOf

// can be enabled for showing logs for these tests
private const val SHOW_LOGS = false

@Suppress("ktlint:standard:argument-list-wrapping")
class DelimCsvTsvTests {

Expand All @@ -45,12 +48,14 @@ class DelimCsvTsvTests {

@Before
fun setLogger() {
if (!SHOW_LOGS) return
loggerBefore = System.getProperty(logLevel)
System.setProperty(logLevel, "debug")
System.setProperty(logLevel, "trace")
}

@After
fun restoreLogger() {
if (!SHOW_LOGS) return
if (loggerBefore != null) {
System.setProperty(logLevel, loggerBefore)
}
Expand Down
4 changes: 0 additions & 4 deletions dataframe-csv/src/test/resources/simplelogger.properties
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,3 @@ org.slf4j.simpleLogger.showLogName=true
# Set to true if you want the last component of the name to be included in output messages.
# Defaults to false.
#org.slf4j.simpleLogger.showShortLogName=false

# Disables FastDoubleParser debug logs by default in our tests
# Can be enabled by setting the system property programmatically
org.slf4j.simpleLogger.log.org.jetbrains.kotlinx.dataframe.impl.io.FastDoubleParser=warn