com.alogic.xscript.plugins.Logger Maven / Gradle / Ivy
package com.alogic.xscript.plugins;
import org.w3c.dom.Element;
import com.alogic.xscript.AbstractLogiclet;
import com.alogic.xscript.ExecuteWatcher;
import com.alogic.xscript.Logiclet;
import com.alogic.xscript.LogicletContext;
import com.alogic.xscript.doc.XsObject;
import com.alogic.xscript.log.Default;
import com.alogic.xscript.log.LogInfo;
import com.anysoft.util.Properties;
import com.anysoft.util.XmlElementProperties;
import com.anysoft.util.XmlTools;
import com.anysoft.stream.Handler;
import com.anysoft.util.Factory;
/**
* 定义日志处理器
*
* @author duanyy
*
* @version 1.6.8.14 [20170509 duanyy]
* - 增加xscript的中间文档模型,以便支持多种报文协议
*
*/
public class Logger extends AbstractLogiclet{
public Logger(String tag, Logiclet p) {
super(tag, p);
}
@Override
protected void onExecute(XsObject root,XsObject current, LogicletContext ctx,
ExecuteWatcher watcher) {
// 不会被执行
}
@Override
public boolean isExecutable() {
return false;
}
@Override
public void configure(Element e, Properties p) {
Properties props = new XmlElementProperties(e,p);
configure(props);
Factory> factory = new Factory>();
try {
Handler logHandler = factory.newInstance(e, props, "module", Default.class.getName());
if (logHandler != null){
Logiclet parent = this.parent();
if (parent != null){
parent.registerLogger(logHandler);
}
}
}catch (Exception ex){
logger.error("Can not create log handler,xml=" + XmlTools.node2String(e));
}
}
}