mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-04 11:24:35 -05:00
Fix/default log level (#719)
* Set default log level to INFO
Default log level was accidentally changed to ERROR for the base logger in 56deea9fb3
* Reduce graphql log level to WARN
Otherwise, thrown exceptions are swallowed by graphql and never logged besides a very brief error in the graphql response
This commit is contained in:
@@ -66,6 +66,16 @@ val serverConfig: ServerConfig by lazy { GlobalConfigManager.module() }
|
|||||||
|
|
||||||
val androidCompat by lazy { AndroidCompat() }
|
val androidCompat by lazy { AndroidCompat() }
|
||||||
|
|
||||||
|
fun setupLogLevelUpdating(
|
||||||
|
configFlow: MutableStateFlow<Boolean>,
|
||||||
|
loggerNames: List<String>,
|
||||||
|
defaultLevel: Level = Level.INFO,
|
||||||
|
) {
|
||||||
|
serverConfig.subscribeTo(configFlow, { debugLogsEnabled ->
|
||||||
|
loggerNames.forEach { loggerName -> setLogLevelFor(loggerName, if (debugLogsEnabled) Level.DEBUG else defaultLevel) }
|
||||||
|
}, ignoreInitialValue = false)
|
||||||
|
}
|
||||||
|
|
||||||
fun applicationSetup() {
|
fun applicationSetup() {
|
||||||
Thread.setDefaultUncaughtExceptionHandler { _, throwable ->
|
Thread.setDefaultUncaughtExceptionHandler { _, throwable ->
|
||||||
KotlinLogging.logger { }.error(throwable) { "unhandled exception" }
|
KotlinLogging.logger { }.error(throwable) { "unhandled exception" }
|
||||||
@@ -81,20 +91,10 @@ fun applicationSetup() {
|
|||||||
|
|
||||||
initLoggerConfig(applicationDirs.dataRoot)
|
initLoggerConfig(applicationDirs.dataRoot)
|
||||||
|
|
||||||
val setupLogLevelUpdating = { configFlow: MutableStateFlow<Boolean>, loggerNames: List<String> ->
|
|
||||||
serverConfig.subscribeTo(configFlow, { debugLogsEnabled ->
|
|
||||||
if (debugLogsEnabled) {
|
|
||||||
loggerNames.forEach { loggerName -> setLogLevelFor(loggerName, Level.DEBUG) }
|
|
||||||
} else {
|
|
||||||
loggerNames.forEach { loggerName -> setLogLevelFor(loggerName, Level.ERROR) }
|
|
||||||
}
|
|
||||||
}, ignoreInitialValue = false)
|
|
||||||
}
|
|
||||||
|
|
||||||
setupLogLevelUpdating(serverConfig.debugLogsEnabled, listOf(BASE_LOGGER_NAME))
|
setupLogLevelUpdating(serverConfig.debugLogsEnabled, listOf(BASE_LOGGER_NAME))
|
||||||
// gql "ExecutionStrategy" spams logs with "... completing field ..."
|
// gql "ExecutionStrategy" spams logs with "... completing field ..."
|
||||||
// gql "notprivacysafe" logs every received request multiple times (received, parsing, validating, executing)
|
// gql "notprivacysafe" logs every received request multiple times (received, parsing, validating, executing)
|
||||||
setupLogLevelUpdating(serverConfig.gqlDebugLogsEnabled, listOf("graphql", "notprivacysafe"))
|
setupLogLevelUpdating(serverConfig.gqlDebugLogsEnabled, listOf("graphql", "notprivacysafe"), Level.WARN)
|
||||||
|
|
||||||
logger.info("Running Tachidesk ${BuildConfig.VERSION} revision ${BuildConfig.REVISION}")
|
logger.info("Running Tachidesk ${BuildConfig.VERSION} revision ${BuildConfig.REVISION}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user