com.cisco.oss.foundation.logging.transactions.ConfigurationUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of logging-api Show documentation
Show all versions of logging-api Show documentation
This project is the logging api library in the cisco vss foundation runtime
package com.cisco.oss.foundation.logging.transactions;
import com.cisco.oss.foundation.configuration.ConfigurationFactory;
import com.cisco.oss.foundation.configuration.FoundationConfigurationListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;
/**
* Created by Nuna on 27/10/2015.
*/
public enum ConfigurationUtil implements FoundationConfigurationListener {
INSTANCE;
private static final Logger LOGGER = LoggerFactory.getLogger(ConfigurationUtil.class);
private boolean verbose = false;
private Environment environment;
ConfigurationUtil() {
reloadConfig();
}
@Override
public void configurationChanged() {
reloadConfig();
}
private void reloadConfig() {
if (environment == null) {
verbose = ConfigurationFactory.getConfiguration().getBoolean("logging.verbose", false);
}else{
verbose = Boolean.valueOf(environment.getProperty("logging.verbose", "false"));
}
}
public boolean isVerbose() {
return verbose;
}
public void setEnvironment(Environment environment){
this.environment = environment;
}
public static void setConfigSource(Environment environment) {
boolean configuredReady = false;
try{
ConfigurationFactory.getConfiguration();
configuredReady = true;
}catch (Exception e){
LOGGER.debug("can't load configuration. Error is: " + e);
}
if (environment != null && !configuredReady){
INSTANCE.setEnvironment(environment);
}
INSTANCE.reloadConfig();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy