1 6 7 package org.jzonic.jlo.processor; 8 9 import org.jzonic.jlo.*; 10 11 import java.util.Vector ; 12 16 public abstract class AbstractLogProcessor implements LogProcessor { 17 18 public AbstractLogProcessor() { 19 } 20 21 public void flush() { 22 } 23 24 public abstract String getProcessorName(); 25 26 public abstract void processEvent(LogGenerator lg, LogRecord lr); 27 28 protected void handle(LogEvent le) { 29 if (le.getFormatter() != null) { 30 String msg = le.getFormatter().formatMessage(le.getLogRecord()); 31 le.getHandler().publish(msg); 32 } else { 33 le.getHandler().publish(le.getLogRecord()); 34 } 35 } 36 37 protected void handleSpecialChannels(LogRecord lr) { 38 if ( lr.getTarget() != null ) { 39 if (LogManager.isChannelOn(lr.getTarget().getName(),lr.getConfigurationName())) { 40 Channel myChannel = LogManager.getChannel(lr.getTarget().getName(),lr.getConfigurationName()); 41 lr.setTarget(lr.getTarget()); 42 LogEvent lec = new LogEvent(myChannel.getLogGenerator().getHandler(), myChannel.getLogGenerator().getFormatter(), lr); 43 handle(lec); 44 } 45 } 46 } 47 48 protected void handlePipes(LogEvent le) { 49 if ( LogManager.getInstance().getLogConfiguration(le.getLogRecord().getConfigurationName()).getLogPipesCount() > 0 ) { 50 Vector pipes = LogManager.getInstance().getLogConfiguration(le.getLogRecord().getConfigurationName()).getLogPipes(); 51 for ( int j = 0; j < pipes.size();j++) { 52 LogPipe pipe = (LogPipe)pipes.get(j); 53 if ( pipe.getFilter() != null ) { 54 if ( pipe.getFilter().match(le.getLogRecord().getMessage() )) { 55 LogEvent myEvent = new LogEvent(pipe.getGenerator().getHandler(),pipe.getGenerator().getFormatter(),le.getLogRecord()); 56 handle(myEvent); 57 } 58 } 59 else { 60 LogEvent myEvent = new LogEvent(pipe.getGenerator().getHandler(),pipe.getGenerator().getFormatter(),le.getLogRecord()); 61 handle(myEvent); 62 } 63 } 64 } 65 } 66 67 } 68 | Popular Tags |