"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ScriptAppenderSelector.java" between
apache-log4j-2.11.1-src.tar.gz and apache-log4j-2.11.2-src.tar.gz

About: Apache Log4j 2 is a logging library for Java. Source distribution (Java).

ScriptAppenderSelector.java  (apache-log4j-2.11.1-src):ScriptAppenderSelector.java  (apache-log4j-2.11.2-src)
skipping to change at line 30 skipping to change at line 30
import java.util.Objects; import java.util.Objects;
import javax.script.Bindings; import javax.script.Bindings;
import org.apache.logging.log4j.core.Appender; import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.Core; import org.apache.logging.log4j.core.Core;
import org.apache.logging.log4j.core.Filter; import org.apache.logging.log4j.core.Filter;
import org.apache.logging.log4j.core.Layout; import org.apache.logging.log4j.core.Layout;
import org.apache.logging.log4j.core.LogEvent; import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.config.Configuration; import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.Property;
import org.apache.logging.log4j.core.config.plugins.Plugin; import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute; import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute;
import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory; import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
import org.apache.logging.log4j.core.config.plugins.PluginConfiguration; import org.apache.logging.log4j.core.config.plugins.PluginConfiguration;
import org.apache.logging.log4j.core.config.plugins.PluginElement; import org.apache.logging.log4j.core.config.plugins.PluginElement;
import org.apache.logging.log4j.core.config.plugins.validation.constraints.Requi red; import org.apache.logging.log4j.core.config.plugins.validation.constraints.Requi red;
import org.apache.logging.log4j.core.script.AbstractScript; import org.apache.logging.log4j.core.script.AbstractScript;
import org.apache.logging.log4j.core.script.ScriptManager; import org.apache.logging.log4j.core.script.ScriptManager;
@Plugin(name = "ScriptAppenderSelector", category = Core.CATEGORY_NAME, elementT ype = Appender.ELEMENT_TYPE, printObject = true) @Plugin(name = "ScriptAppenderSelector", category = Core.CATEGORY_NAME, elementT ype = Appender.ELEMENT_TYPE, printObject = true)
skipping to change at line 64 skipping to change at line 65
@PluginBuilderAttribute @PluginBuilderAttribute
@Required @Required
private String name; private String name;
@PluginElement("Script") @PluginElement("Script")
@Required @Required
private AbstractScript script; private AbstractScript script;
@Override @Override
public Appender build() { public Appender build() {
if (name == null) { if (name == null) {
LOGGER.error("Name missing."); LOGGER.error("Name missing.");
return null; return null;
} }
if (script == null) { if (script == null) {
LOGGER.error("Script missing for ScriptAppenderSelector appender LOGGER.error("Script missing for ScriptAppenderSe
{}", name); lector appender {}", name);
return null; return null;
} }
if (appenderSet == null) { if (appenderSet == null) {
LOGGER.error("AppenderSet missing for ScriptAppenderSelector app LOGGER.error("AppenderSet missing for ScriptAppen
ender {}", name); derSelector appender {}", name);
return null; return null;
} }
if (configuration == null) { if (configuration == null) {
LOGGER.error("Configuration missing for ScriptAppenderSelector a LOGGER.error("Configuration missing for ScriptApp
ppender {}", name); enderSelector appender {}", name);
return null; return null;
} }
final ScriptManager scriptManager = configuration.getScriptManager() final ScriptManager scriptManager = configuration.getScri
; ptManager();
scriptManager.addScript(script); scriptManager.addScript(script);
final Bindings bindings = scriptManager.createBindings(script); final Bindings bindings = scriptManager.createBindings(sc
final Object object = scriptManager.execute(script.getName(), bindin ript);
gs); LOGGER.debug("ScriptAppenderSelector '{}' executing {} '{
final String appenderName = Objects.toString(object, null); }': {}", name, script.getLanguage(),
final Appender appender = appenderSet.createAppender(appenderName, n script.getName(), script.getScriptText())
ame); ;
return appender; final Object object = scriptManager.execute(script.getNam
} e(), bindings);
final String actualAppenderName = Objects.toString(object
, null);
LOGGER.debug("ScriptAppenderSelector '{}' selected '{}'",
name, actualAppenderName);
return appenderSet.createAppender(actualAppenderName, nam
e);
}
public AppenderSet getAppenderSet() { public AppenderSet getAppenderSet() {
return appenderSet; return appenderSet;
} }
public Configuration getConfiguration() { public Configuration getConfiguration() {
return configuration; return configuration;
} }
public String getName() { public String getName() {
skipping to change at line 133 skipping to change at line 136
return this; return this;
} }
} }
@PluginBuilderFactory @PluginBuilderFactory
public static Builder newBuilder() { public static Builder newBuilder() {
return new Builder(); return new Builder();
} }
private ScriptAppenderSelector(final String name, final Filter filter, final private ScriptAppenderSelector(final String name, final Filter filter, final
Layout<? extends Serializable> layout) { Layout<? extends Serializable> layout,
super(name, filter, layout); final Property[] properties) {
super(name, filter, layout, true, Property.EMPTY_ARRAY);
} }
@Override @Override
public void append(final LogEvent event) { public void append(final LogEvent event) {
// Do nothing: This appender is only used to discover and build another appender // Do nothing: This appender is only used to discover and build another appender
} }
} }
 End of changes. 3 change blocks. 
34 lines changed or deleted 43 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)