protected String getLogBuffer(
      VariableSpace space, String logChannelId, LogStatus status, String limit) {

    StringBuffer buffer = KettleLogStore.getAppender().getBuffer(logChannelId, true);

    if (Const.isEmpty(limit)) {
      String defaultLimit = space.getVariable(Const.KETTLE_LOG_SIZE_LIMIT, null);
      if (!Const.isEmpty(defaultLimit)) {
        limit = defaultLimit;
      }
    }

    // See if we need to limit the amount of rows
    //
    int nrLines = Const.isEmpty(limit) ? -1 : Const.toInt(space.environmentSubstitute(limit), -1);

    if (nrLines > 0) {
      int start = buffer.length() - 1;
      for (int i = 0; i < nrLines && start > 0; i++) {
        start = buffer.lastIndexOf(Const.CR, start - 1);
      }
      if (start > 0) {
        buffer.delete(0, start + Const.CR.length());
      }
    }

    return buffer.append(Const.CR + status.getStatus().toUpperCase() + Const.CR).toString();
  }
示例#2
0
文件: Log.java 项目: Serhiy1996/i
 public String sText() {
   StringBuilder osText = new StringBuilder();
   osText.append(" | ").append(oStatus == null ? "" : oStatus.name()).append(" |");
   osText.append(" | ").append(oClass == null ? "" : oClass.getName()).append(" |");
   osText.append(" [").append(sCase == null ? "" : sCase).append("]");
   osText.append("{").append(nStatusHTTP == null ? "" : nStatusHTTP).append("}");
   // TODO: do params for standart slf4j: "Object[] os" and (param1={}, param1={})
   osText.append("(").append(mParam == null ? "" : mParam).append(")");
   osText
       .append(":")
       .append(
           sHead != null
               ? sHead + (oException != null ? " " + oException.getMessage() : "")
               : oException != null ? oException.getMessage() : "");
   if (sBody != null) {
     osText.append("\n").append(sBody);
   }
   return osText.toString();
 }