Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package cl.alma.camel.acslog;
  
 
 import  com.cosylab.logging.engine.ACS.ACSRemoteErrorListener;
 import  com.cosylab.logging.engine.ACS.ACSRemoteLogListener;
 import  com.cosylab.logging.engine.audience.Audience;
 import  com.cosylab.logging.engine.audience.Audience.AudienceInfo;
 import  com.cosylab.logging.engine.log.ILogEntry;
 import  com.cosylab.logging.engine.log.LogTypeHelper;

This class consume ACS logs from the logging channel. Inherit jLog classes in order to connect to ACS, must be defined -DACS.manager=$MANAGER_REFERENCE if -DACS.tmp=$ACS_TMP is defined, also should be as well: -Djlog.cache.size=4096 -Djlog.cache.writebuffersize=1024

Author(s):
atejeda
 
 public abstract class ACSLogConsumer extends DefaultConsumer implements ACSRemoteLogListener, ACSRemoteErrorListener {
     	
 	protected final ACSLogEndpoint endpoint;
 
 	public ACSLogConsumer(Endpoint endpointProcessor processor) {
 		super(endpointprocessor);
 		this. = (ACSLogEndpointendpoint;
 	}

   
Returns the audience for reading the log, defined in the endpoint, ACS logging api use this as a filter.

Returns:
the audience, by default: Enginner.
 
 	public Audience getAudience() {
 		String audienceString = this..getAudience();
 		Audience audience;
 		audience = AudienceInfo.fromShortName(audienceString).getAudience();
 		if(audience == null) {
 			audience = AudienceInfo.ENGINEER.getAudience();
 		}
 		return audience;
 	}

Returns the discard level for reading the log, defined in the endpoint, ACS logging api use this as a filter.

Returns:
the discard level, by default: Debug.
 
 	public LogTypeHelper getLogDiscardLevel() {
 		String logdiscardString = this..getDiscard();
 		LogTypeHelper logDiscard;
 		logDiscard = LogTypeHelper.fromLogTypeDescription(logdiscardString);
 		if(logDiscard == null) {
 			logDiscard= LogTypeHelper.DEBUG;
 		}
 		return logDiscard;
 	}

Returns the log level for reading the log, defined in the endpoint, ACS logging api use this as a filter.

Returns:
the log level, by default: Info.
 
 	public LogTypeHelper getLogLevel() {
 		String loglevelString = this..getLevel();
 		LogTypeHelper loglevel;
 		loglevel = LogTypeHelper.fromLogTypeDescription(loglevelString);
 		if(loglevel == null) {
 			loglevel= LogTypeHelper.INFO;
 		}
 		return loglevel;
 	}

Receive a log entry from the xml files, updates the read log count and the read log parsed count, also add the "origin" field to the data file of the ACS logging api structure, the purpuse is to identify the origin of this log, eg.: my-localhost-name.
Also it will create the Camel exchange to be sent to the processor.
 
 	public void logEntryReceived(ILogEntry logEntry) {
 		try {
 			this.getProcessor().process(this.createExchange(logEntry));
 		} catch (Exception e) {
 		}
 	}

Parameters:
logEntry
Returns:
    public Exchange createExchange(ILogEntry logEntry) {
    	Exchange exchange = new DefaultExchange(this..getCamelContext(), 
    	
    	Message message = new DefaultMessage();
    	
    	switch(this..getModeEnum()) {
    		case :
    			message.setBody(this.wrappedLogEntry(logEntry));
    			break;
    		case :
    			logEntry.addData("origin"this..getOrigin());
        		message.setBody(logEntry.toXMLString());
        		break;
    		case :
    			logEntry.addData("origin"this..getOrigin());
        		message.setBody(logEntry);
        		break;
        	default:
        		message.setBody(this.wrappedLogEntry(logEntry));
        		break;
    	}
    	
    	exchange.setIn(message);
    	return exchange;
    }

Parameters:
logEntry
Returns:
	public Object wrappedLogEntry(ILogEntry logEntry) {
		return new ACSLogEntryWrapper(logEntrythis..getOrigin());
	}
New to GrepCode? Check out our FAQ X