示例#1
0
 /**
  * Build the string for the cache out of an ILogEntry for the case of binary logs
  *
  * @param log The log to get the cache string in binary format
  * @return The cache string (binary format)
  */
 private synchronized String toCacheString(ILogEntry log) throws Exception {
   LogBinaryRecord logBin = convertLogToBinary(log);
   String str = null;
   try {
     str = com.cosylab.logging.engine.ACS.CacheUtils.toCacheString(logBin);
   } catch (Throwable t) {
     t.printStackTrace(System.err);
     System.err.println("Log with error " + logBin.toString());
   }
   return str;
 }
示例#2
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;
 }