Esempio n. 1
0
  private static String buildNonLoggableDesc(LogEntry logEntry) {
    StringBuffer buf = new StringBuffer();

    buf.append("Log Data [Level=");
    buf.append(logEntry.level);
    if (!Str.isEmpty(logEntry.compId)) {
      buf.append(" CompID=");
      buf.append(logEntry.compId);
    }

    if (-1 != logEntry.transKey) {
      buf.append(" RcvdFaxKey=");
      buf.append(logEntry.transKey);
    }

    if (!Str.isEmpty(logEntry.sessionId)) {
      buf.append("; UniqueID=");
      buf.append(logEntry.sessionId);
    }

    buf.append(" Thread=");
    buf.append(logEntry.threadId);
    buf.append(" Desc=");
    buf.append(logEntry.desc);
    buf.append("]");

    return buf.toString();
  }
Esempio n. 2
0
  @Override
  public void logWs(LogLevel severity, WsRequest req, String logText) {
    if (!isInit) {
      init();
    }

    String sql =
        "insert into "
            + TABLE_LOG_WS
            + "( date, severity, machine_name, entity_code, action, description, request, millis ) "
            + "values ( getutcdate(),?,?,?,?,?,?,? )";

    long millis = System.currentTimeMillis() - req.getStartTime();
    Sql.sqlExe(
        sql,
        new Object[] {
          severity.toString(),
          Util.getHostName(),
          req.getCompId(),
          req.getVerb(),
          Str.truncate(logText, 2048),
          null == req.getXmlRequest() ? "" : Str.truncate(req.getXmlRequest(), 4096),
          millis
        },
        new int[] {
          Types.VARCHAR,
          Types.VARCHAR,
          Types.VARCHAR,
          Types.VARCHAR,
          Types.VARCHAR,
          Types.VARCHAR,
          Types.INTEGER
        },
        Context.rf.get().getLogRF());
  }
Esempio n. 3
0
  /**
   * We're about to push the info to the log, so do final adjustments on the logEntry object,
   * setting up data.
   *
   * @param logEntry LogEntry that holds the info to be logged
   * @param factory ResourceFactory the source for the DB connection
   */
  private static void prepLogEntry(LogEntry logEntry, ResourceFactory factory) {
    if (null == logEntry.serviceName) {
      logEntry.serviceName = factory.getSystemName();
    }

    StringBuilder desc = new StringBuilder(MAX_LOG_DESC);
    if (logEntry.clazz != null) {
      String className = logEntry.clazz.getName();
      int idx = className.lastIndexOf('.');

      desc.append(idx == -1 ? className : className.substring(idx + 1));
      desc.append(".");
      desc.append(logEntry.method);
    }

    if (!Str.isEmpty(logEntry.desc)) {
      desc.append(" ");
      desc.append(logEntry.desc);
    }

    if (logEntry.throwable != null) {
      desc.append(" Exception: ");
      if (logEntry.level.ordinal() >= factory.getStackTraceLevel().ordinal()) {
        desc.append(System.getProperty("line.separator"));
        desc.append(Stack.getShortStack(logEntry.throwable));
      } else {
        desc.append(logEntry.throwable.toString());
      }
    }

    logEntry.desc = desc.substring(0, Math.min(MAX_LOG_DESC, desc.length()));
  }
Esempio n. 4
0
  @Override
  public String getConfigs(String token) {
    if (!isInit) {
      init();
    }

    ResourceFactory rf = Context.rf.get();
    final Map<String, Object> sessRec = findSession(token, rf);

    String sql =
        "select "
            + COL_TUPLE_KEY
            + ","
            + COL_TUPLE_VALUE
            + " from "
            + TABLE_CONFIG
            + " with(nolock) where CONNECTOR_KEY=?";

    ResultSet rs =
        Sql.sqlQuery(
            sql, new Object[] {sessRec.get(COL_CONNECTOR_ID)}, new int[] {Types.INTEGER}, rf);
    try {
      StringBuilder buf = new StringBuilder(1024);
      while (rs.next()) {
        buf.append("<tuple>");
        buf.append("<key>").append(rs.getString(1)).append("</key>");
        buf.append("<data>").append(Str.cdata(rs.getString(2))).append("</data>");
        buf.append("</tuple>");
      }

      return buf.toString();
    } catch (RuntimeException rte) {
      throw rte;
    } catch (Throwable t) {
      throw new IllegalStateException(t);
    } finally {
      Sql.closeAll(rs);
    }
  }