Skip to content

Commit 2fadca0

Browse files
committed
Better config logging
1 parent 704c9be commit 2fadca0

File tree

1 file changed

+10
-3
lines changed
  • stubbornjava-common/src/main/java/com/stubbornjava/common

1 file changed

+10
-3
lines changed

stubbornjava-common/src/main/java/com/stubbornjava/common/Configs.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ public static Config properties() {
3030
return properties;
3131
}
3232

33+
// This should return the current executing user path
34+
public static String getExecutionDirectory() {
35+
return system.getString("user.dir");
36+
}
37+
3338
public static Map<String, Object> asMap(Config config) {
3439
return Seq.seq(config.entrySet())
3540
.toMap(e -> e.getKey(), e -> e.getValue().unwrapped());
@@ -66,14 +71,16 @@ public Builder envAwareApp() {
6671
}
6772

6873
public Builder withSecureConf() {
69-
return withOptionalFile("./secure.conf");
74+
return withOptionalFile(getExecutionDirectory() + "/secure.conf");
7075
}
7176

7277
public Config build() {
7378
// Resolve substitutions.
7479
conf = conf.resolve();
75-
log.debug("Logging properties. Make sure sensitive data such as passwords or secrets are not logged!");
76-
log.debug(conf.root().render(ConfigRenderOptions.concise().setFormatted(true)));
80+
if (log.isDebugEnabled()) {
81+
log.debug("Logging properties. Make sure sensitive data such as passwords or secrets are not logged!");
82+
log.debug(conf.root().render(ConfigRenderOptions.concise().setFormatted(true)));
83+
}
7784
return conf;
7885
}
7986

0 commit comments

Comments
 (0)