Пример #1
0
  /**
   * Print a text to the log (usually derby.log), provided that verbose is true.
   *
   * @param text The text that will be logged
   * @param writeHeader if true, encapsulates message in "begin error message" and "end error
   *     message" lines. If false, timestamps the text and writes it to the log without the header
   *     and footer.
   */
  public void logText(String text, boolean writeHeader) {

    if (verbose) {
      if (writeHeader) {
        Monitor.logTextMessage(MessageId.REPLICATION_ERROR_BEGIN, new Date());
        Monitor.logMessage(text);
        Monitor.logTextMessage(MessageId.REPLICATION_ERROR_END);
      } else {
        Monitor.logTextMessage(MessageId.REPLICATION_ONELINE_MSG_HEADER, new Date(), text);
      }
    }
  }
Пример #2
0
  /**
   * Print error message and the stack trace of the throwable to the log (usually derby.log)
   * provided that verbose is true. If verbose is false, nothing is logged.
   *
   * @param msgId The error message id
   * @param t Error trace starts from this error
   */
  public void logError(String msgId, Throwable t) {

    if (verbose) {

      Monitor.logTextMessage(MessageId.REPLICATION_ERROR_BEGIN, new Date());

      if (msgId != null) {
        Monitor.logTextMessage(msgId, dbname);
      }

      if (t != null) {
        ErrorStringBuilder esb = new ErrorStringBuilder(Monitor.getStream().getHeader());
        esb.stackTrace(t);
        Monitor.logMessage(esb.get().toString());
        esb.reset();
      }
      Monitor.logTextMessage(MessageId.REPLICATION_ERROR_END);
    }
  }