forked from CharlesSkelton/studio
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from dzmipt/finosConfigFolderConfiguration
config and log folder can be set with KDBSTUDIO_CONFIG_HOME variable
- Loading branch information
Showing
8 changed files
with
88 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package studio.utils.log4j; | ||
|
||
import org.apache.logging.log4j.core.LogEvent; | ||
import org.apache.logging.log4j.core.config.plugins.Plugin; | ||
import org.apache.logging.log4j.core.lookup.StrLookup; | ||
|
||
@Plugin(name="studiobase", category = StrLookup.CATEGORY) | ||
public class EnvConfig implements StrLookup { | ||
|
||
private final static String environment = System.getProperty("env"); | ||
private final static String homeFolder = getValue("KDBSTUDIO_CONFIG_HOME", System.getProperty("user.home") + "/.studioforkdb"); | ||
|
||
public static String getEnvironment() { | ||
return environment; | ||
} | ||
|
||
public static String getBaseFolder(String env) { | ||
return env == null ? homeFolder : homeFolder + "/" + env; | ||
} | ||
|
||
public static String getBaseFolder() { | ||
return getBaseFolder(environment); | ||
} | ||
|
||
public static String getFilepath(String env, String filename) { | ||
return getBaseFolder(env) + "/" + filename; | ||
} | ||
|
||
public static String getFilepath(String filename) { | ||
return getFilepath(environment, filename); | ||
} | ||
|
||
private static String getValue(String key, String defaultValue) { | ||
String value = System.getProperty(key, System.getenv(key)); | ||
return value == null ? defaultValue : value; | ||
} | ||
|
||
@Override | ||
public String lookup(String key) { | ||
return getFilepath(key); | ||
} | ||
|
||
@Override | ||
public String lookup(LogEvent event, String key) { | ||
return lookup(key); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters