Example usage for java.util.logging LogRecord getSequenceNumber

List of usage examples for java.util.logging LogRecord getSequenceNumber

Introduction

In this page you can find the example usage for java.util.logging LogRecord getSequenceNumber.

Prototype

public long getSequenceNumber() 

Source Link

Document

Get the sequence number.

Usage

From source file:hudson.logging.LogRecorderManager.java

/**
 * Renders the given log recorders as RSS.
 *//*from  w ww .j av a2  s  .c o m*/
/*package*/ static void doRss(StaplerRequest req, StaplerResponse rsp, List<LogRecord> logs)
        throws IOException, ServletException {
    // filter log records based on the log level
    String level = req.getParameter("level");
    if (level != null) {
        Level threshold = Level.parse(level);
        List<LogRecord> filtered = new ArrayList<LogRecord>();
        for (LogRecord r : logs) {
            if (r.getLevel().intValue() >= threshold.intValue())
                filtered.add(r);
        }
        logs = filtered;
    }

    RSS.forwardToRss("Hudson log", "", logs, new FeedAdapter<LogRecord>() {
        public String getEntryTitle(LogRecord entry) {
            return entry.getMessage();
        }

        public String getEntryUrl(LogRecord entry) {
            return "log"; // TODO: one URL for one log entry?
        }

        public String getEntryID(LogRecord entry) {
            return String.valueOf(entry.getSequenceNumber());
        }

        public String getEntryDescription(LogRecord entry) {
            return Functions.printLogRecord(entry);
        }

        public Calendar getEntryTimestamp(LogRecord entry) {
            GregorianCalendar cal = new GregorianCalendar();
            cal.setTimeInMillis(entry.getMillis());
            return cal;
        }

        public String getEntryAuthor(LogRecord entry) {
            return Mailer.descriptor().getAdminAddress();
        }
    }, req, rsp);
}

From source file:simj.util.logging.HTMLFormatter.java

private String getLogEntry(final LogRecord record) {
    StringBuffer buf = new StringBuffer(2048);

    buf.append("<TR>\n");
    buf.append("<TD><DIV ALIGN=\"right\">");
    buf.append(record.getSequenceNumber());
    buf.append("</DIV></TD>");
    buf.append("<TD>");

    // Bold any levels >= INFO, for instance severe error messages.
    if (record.getLevel().intValue() >= Level.INFO.intValue()) {
        buf.append("<b>");

        if (record.getLevel().intValue() >= Level.WARNING.intValue()) {
            buf.append("<i>");
            buf.append(record.getLevel());
            buf.append("</i>");
        } else {//from  www . j a v a2s .co m
            buf.append(record.getLevel());
        }

        buf.append("</b>");
    } else {
        buf.append(record.getLevel());
    }

    buf.append("</TD>");
    buf.append("<TD>");
    buf.append(record.getMillis());
    buf.append("</TD>");
    buf.append("<TD>");
    buf.append(record.getSourceClassName());
    buf.append("</TD>");
    buf.append("<TD>");
    buf.append(record.getSourceMethodName());
    buf.append("</TD>");
    buf.append("<TD>");
    buf.append("\n</TR>\n");
    buf.append("<TR>\n");
    buf.append("<TD>");
    buf.append("</TD>");
    buf.append("<TD COLSPAN=\"4\">");
    buf.append("<EM>");
    buf.append(cleanUpHTML(formatMessage(record)));
    buf.append("</EM>");
    buf.append("</TD>");
    buf.append("\n</TR>\n");
    buf.append("<TR>");
    buf.append("<TD COLSPAN=\"5\"><HR SIZE=\"1\" NOSHADE></TD>");
    buf.append("</TR>\n\n");

    return buf.toString();
}