com.cisco.oss.foundation.logging.transactions.LoggingKeysHandler 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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
/**
* Created by yzalazni on 1/22/2017.
*/
public class LoggingKeysHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(LoggingKeysHandler.class);
private Map keysMap;
//generate a map with the logging available keys
public LoggingKeysHandler(InputStream propertiesInputStream) {
loadKeysFromStream(propertiesInputStream);
}
private void loadKeysFromStream(InputStream propertiesInputStream){
Properties properties = new Properties();
try {
properties.load(propertiesInputStream);
propertiesInputStream.close();
}
catch (Exception e) {
LOGGER.error("Some issue finding or loading logging keys properties file. " + e.getMessage());
}
keysMap = (Map)properties;
}
//get the key name to use in log from the logging keys map
public String getKeyValue(String key){
String keyName = keysMap.get(key);
if (keyName != null){
return keyName;
}
return ""; //key wasn't defined in keys properties file
}
public int getMapSize(){
return keysMap.size();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy