com.firefly.utils.log.PropertiesLogConfigParser Maven / Gradle / Ivy
package com.firefly.utils.log;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.Map.Entry;
import com.firefly.utils.StringUtils;
import com.firefly.utils.function.Action1;
import com.firefly.utils.log.file.FileLog;
public class PropertiesLogConfigParser extends AbstractLogConfigParser {
@Override
public boolean parse(Action1 action) {
try {
Properties properties = loadLogConfigurationFile();
if (properties != null) {
parseProperties(properties, action);
return true;
} else {
return false;
}
} catch (IOException e) {
System.err.println("parse exception, " + e.getMessage());
return false;
}
}
private Properties loadLogConfigurationFile() throws IOException {
Properties properties = new Properties();
try (InputStream input = LogFactory.class.getClassLoader()
.getResourceAsStream(DEFAULT_PROPERTIES_CONFIG_FILE_NAME)) {
if (input == null)
return null;
properties.load(input);
}
return properties;
}
private void parseProperties(Properties properties, Action1 fileLog) {
for (Entry
© 2015 - 2025 Weber Informatics LLC | Privacy Policy