Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.graylog2.syslog4j.server.impl.event.structured;
  
  
SyslogServerStructuredEvent provides an implementation of the SyslogServerEventIF interface that supports receiving of structured syslog messages, as defined in:

http://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6

Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy of the LGPL license is available in the META-INF folder in all distributions of Syslog4j and in the base directory of the "doc" ZIP.

Author(s):
Manish Motwani
Version:
$Id: StructuredSyslogServerEvent.java,v 1.6 2011/01/11 05:11:13 cvs Exp $
 
 public class StructuredSyslogServerEvent extends SyslogServerEvent {
     private static final long serialVersionUID = 1676499796406044315L;
 
     protected String processId = null;
     protected DateTime dateTime = null;
     protected DateTimeFormatter dateTimeFormatter = null;
 
     public StructuredSyslogServerEvent(final byte[] messageint lengthInetAddress inetAddress) {
         super();
 
         initialize(messagelengthinetAddress);
         parse();
     }
 
     public StructuredSyslogServerEvent(final String messageInetAddress inetAddress) {
         super();
 
         initialize(messageinetAddress);
         parse();
     }
 
         if ( == null) {
             this. = ISODateTimeFormat.dateTimeParser();
         }
 
         return ;
     }
 
     public void setDateTimeFormatter(Object dateTimeFormatter) {
         this. = (DateTimeFormatterdateTimeFormatter;
     }
 
     protected void parseApplicationName() {
         int i = this..indexOf(' ');
 
         if (i > -1) {
             this. = this..substring(0, i).trim();
             this. = this..substring(i + 1);
             parseProcessId();
         }
 
             this. = null;
         }
     }
 
     protected void parseProcessId() {
         int i = this..indexOf(' ');
 
         if (i > -1) {
             this. = this..substring(0, i).trim();
             this. = this..substring(i + 1);
         }
 
             this. = null;
         }
     }
 
     protected void parseDate() {
         // skip VERSION field
         int i = this..indexOf(' ');
         this. = this..substring(i + 1);
 
         // parse the date
         i = this..indexOf(' ');
 
         if (i > -1) {
            String dateString = this..substring(0, i).trim();
            try {
                DateTimeFormatter formatter = getDateTimeFormatter();
                this. = formatter.parseDateTime(dateString);
                this. = this..toDate();
                this. = this..substring(dateString.length() + 1);
            } catch (Exception e) {
                // Not structured date format, try super one
                super.parseDate();
            }
        }
    }
    protected void parseHost() {
        int i = this..indexOf(' ');
        if (i > -1) {
            this. = this..substring(0, i).trim();
            this. = this..substring(i + 1);
            parseApplicationName();
        }
    }
    public String getApplicationName() {
        return this.;
    }
    public String getProcessId() {
        return this.;
    }
    public DateTime getDateTime() {
        return this.;
    }
        try {
            return StructuredSyslogMessage.fromString(getMessage());
        } catch (IllegalArgumentException e) {
            // throw new SyslogRuntimeException(
            // "Message received is not a valid structured message: "
            // + getMessage(), e);
            return new StructuredSyslogMessage(nullnullgetMessage());
        }
    }
New to GrepCode? Check out our FAQ X