예제 #1
0
 @Override
 protected void publish(LogEntry entry) {
   Level level = levelMap.get(entry.getLevel());
   if (level == null) {
     level = Level.INFO;
   }
   this.handle.log(
       level, DefaultFormat.parseArgs(entry.getMessage(), entry.getArgs()), entry.getThrowable());
 }
예제 #2
0
 public void writeEntry(LogEntry logEntry, StringBuilder builder) {
   String message = String.valueOf(logEntry.getMessage());
   Map<String, Object> map = new HashMap<String, Object>();
   if (logEntry.hasArgs()) {
     message = DefaultFormat.parseArgs(message, logEntry.getArgs());
   }
   map.put("msg", message);
   map.put("date", dateFormat.format(logEntry.getDate()));
   map.put("level", logEntry.getLevel().getName());
   builder.append(MACRO_PROCESSOR.process(format, map)).append("\n");
   writeThrowable(logEntry, builder);
 }
예제 #3
0
 private void writeThrowable(LogEntry logEntry, StringBuilder builder) {
   if (logEntry.hasThrowable()) {
     Throwable throwable = logEntry.getThrowable();
     if (throwable.getLocalizedMessage() != null
         && !throwable.getLocalizedMessage().equals(logEntry.getMessage())) {
       builder.append(logEntry.getMessage()).append("\n");
     }
     do {
       builder.append(throwable.getClass().getName());
       if (throwable.getLocalizedMessage() != null) {
         builder.append(": ").append(throwable.getLocalizedMessage());
       }
       builder.append("\n");
       for (StackTraceElement element : throwable.getStackTrace()) {
         builder.append("\tat ").append(element).append("\n");
       }
       throwable = throwable.getCause();
       if (throwable != null) {
         builder.append("Caused by: ");
       }
     } while (throwable != null);
   }
 }
예제 #4
0
 public boolean accept(LogEntry entry) {
   entry.setMessage(prefix + entry.getMessage());
   return true;
 }