List of usage examples for java.util.logging LogRecord getSourceMethodName
public String getSourceMethodName()
From source file:org.fornax.cartridges.sculptor.smartclient.server.util.UnifiedFormatter.java
@Override public String format(LogRecord record) { String username = "ANONYMOUS"; if (SecurityContextHolder.getContext() != null && SecurityContextHolder.getContext().getAuthentication() != null && SecurityContextHolder.getContext().getAuthentication().getPrincipal() != null) { Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal(); if (principal instanceof User) { username = ((User) principal).getUsername(); } else {//from ww w. java 2s . c o m username = principal.toString(); } } int dotIndex = record.getSourceClassName().lastIndexOf("."); String className = record.getSourceClassName().substring(dotIndex != -1 ? dotIndex + 1 : 0); String msg = record.getMessage(); if (record.getParameters() != null && record.getParameters().length > 0) { msg = MessageFormat.format(record.getMessage(), record.getParameters()); } if (record.getThrown() != null) { Throwable thrown = record.getThrown(); StringWriter result = new StringWriter(); thrown.printStackTrace(new PrintWriter(result)); result.flush(); msg += "\n" + result.getBuffer(); } return FST + dateFormat.format(record.getMillis()) + FET + FSEP + RST + FST + record.getLevel() + FET + FSEP + FST + className + "." + record.getSourceMethodName() + FET + FSEP + FST + username + FET + FSEP + FST + record.getThreadID() + FET + FSEP + FST + msg + FET + RET; }
From source file:org.dstadler.commons.logging.jdk.PatternFormatter.java
@Override public String format(LogRecord record) { Date time = new Date(record.getMillis()); String formattedTime = dateFormat.format(time); final String logMessage; if (record.getThrown() == null) { Object[] log = { record.getLoggerName(), record.getLevel(), formattedTime, record.getMessage(), record.getSourceClassName(), record.getSourceMethodName() }; logMessage = logMessageFormat.format(log); } else {/*w w w. ja v a 2s .c o m*/ String stack = getStackLayout(record.getThrown(), ""); Object[] log = { record.getLoggerName(), record.getLevel(), formattedTime, record.getMessage(), record.getSourceClassName(), record.getSourceMethodName(), record.getThrown().getMessage(), stack }; logMessage = exceptionMessageFormat.format(log); } return logMessage; }
From source file:org.ebayopensource.turmeric.runtime.tests.common.jetty.SimpleConsoleHandler.java
@Override public void publish(LogRecord record) { StringBuilder buf = new StringBuilder(); buf.append("[").append(record.getLevel().getName()); buf.append("] ").append(record.getLoggerName()); buf.append(" (").append(record.getSourceMethodName()); buf.append("): ").append(record.getMessage()); System.out.println(buf.toString()); if (record.getThrown() != null) { record.getThrown().printStackTrace(System.out); }//from w w w.j av a 2 s . c o m }
From source file:org.energy_home.jemma.javagal.launcher.main.java
@Override public String format(LogRecord record) { className = record.getSourceClassName(); lastDotInClassName = className.lastIndexOf('.'); className = className.substring(lastDotInClassName + 1, className.length()); return "\n" + className + " " + record.getSourceMethodName() + ": " + record.getMessage(); }
From source file:pl.otros.logview.logging.GuiJulHandler.java
@Override public void publish(LogRecord lr) { if (isIgnoringLogRecord(lr)) { return;/*from w w w.j a v a 2s . c o m*/ } LogData ld = new LogData(); ld.setMessage(lr.getMessage()); ld.setDate(new Date(lr.getMillis())); ld.setFile("Olv-internal"); ld.setClazz(lr.getSourceClassName()); ld.setMethod(lr.getSourceMethodName()); ld.setThread(Integer.toString(lr.getThreadID())); ld.setLevel(lr.getLevel()); if (bufferingLogDataCollectorProxy != null) { bufferingLogDataCollectorProxy.add(ld); } }
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 va2 s . 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(); }