Skip to content

Commit 9f873b5

Browse files
committed
KTOR-6610: feat: add debug log of ConfigLoader when server starts
1 parent af24a5a commit 9f873b5

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

ktor-server/ktor-server-core/common/src/io/ktor/server/config/ConfigLoaders.kt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44

55
package io.ktor.server.config
66

7+
import io.ktor.util.logging.*
8+
79
internal expect val CONFIG_PATH: List<String>
810

11+
private val logger = KtorSimpleLogger("io.ktor.server.config.ConfigLoader")
12+
913
/**
1014
* Loads an application configuration.
1115
* An implementation of this interface should return [ApplicationConfig] if applicable configuration is found
@@ -51,23 +55,34 @@ public interface ConfigLoader {
5155
*/
5256
public fun load(path: String? = null): ApplicationConfig {
5357
if (path == null) {
58+
logger.debug("Loading default configuration")
5459
val default = loadDefault()
5560
if (default != null) return default
5661
}
5762

5863
for (loader in configLoaders) {
64+
logger.debug("Trying ConfigLoader: ${loader::class.simpleName}")
5965
val config = loader.load(path)
60-
if (config != null) return config
66+
if (config != null) {
67+
logger.debug("Configuration loaded successfully using ${loader::class.simpleName} from path: $path")
68+
return config
69+
}
6170
}
6271

72+
logger.debug("No configuration found, using empty MapApplicationConfig")
6373
return MapApplicationConfig()
6474
}
6575

6676
private fun loadDefault(): ApplicationConfig? {
6777
for (defaultPath in CONFIG_PATH) {
78+
logger.debug("Trying default config path: $defaultPath")
6879
for (loader in configLoaders) {
80+
logger.debug("Trying ConfigLoader: ${loader::class.simpleName} for path: $defaultPath")
6981
val config = loader.load(defaultPath)
70-
if (config != null) return config
82+
if (config != null) {
83+
logger.debug("Default configuration loaded using ${loader::class.simpleName} from path: $defaultPath")
84+
return config
85+
}
7186
}
7287
}
7388

0 commit comments

Comments
 (0)