Exemple #1
0
 /**
  * Convert a ILogEntry into a binary log
  *
  * @param The log to convert
  * @return The binary log
  */
 private LogBinaryRecord convertLogToBinary(ILogEntry log) throws Exception {
   LogBinaryRecord logBin = new LogBinaryRecord();
   logBin.Audience = (String) log.getField(LogField.AUDIENCE);
   logBin.File = (String) log.getField(LogField.FILE);
   logBin.Host = (String) log.getField(LogField.HOST);
   Integer line = (Integer) log.getField(LogField.LINE);
   if (line != null) {
     logBin.Line = line;
   } else {
     logBin.Line = 0;
   }
   logBin.LogContext = (String) log.getField(LogField.CONTEXT);
   logBin.LogId = (String) log.getField(LogField.LOGID);
   logBin.MsgData = (String) log.getField(LogField.LOGMESSAGE);
   Integer priority = (Integer) log.getField(LogField.PRIORITY);
   if (priority != null) {
     logBin.Priority = priority;
   } else {
     logBin.Priority = 0;
   }
   logBin.Process = (String) log.getField(LogField.PROCESS);
   logBin.Routine = (String) log.getField(LogField.ROUTINE);
   logBin.SourceObject = (String) log.getField(LogField.SOURCEOBJECT);
   logBin.StackId = (String) log.getField(LogField.STACKID);
   Integer stackL = (Integer) log.getField(LogField.STACKLEVEL);
   if (stackL != null) {
     logBin.StackLevel = stackL;
   } else {
     logBin.StackLevel = 0;
   }
   logBin.Thread = (String) log.getField(LogField.THREAD);
   final Date date = new Date((Long) log.getField(LogField.TIMESTAMP));
   logBin.TimeStamp = IsoDateFormat.formatDate(date);
   logBin.type = (short) log.getType().ordinal();
   logBin.Uri = (String) log.getField(LogField.URI);
   if (log.hasDatas()) {
     Vector<AdditionalData> data = log.getAdditionalData();
     logBin.log_data = new NameValue[data.size()];
     for (int t = 0; t < data.size(); t++) {
       AdditionalData d = data.get(t);
       logBin.log_data[t] = new NameValue(d.name, d.value);
     }
   }
   return logBin;
 }