Ejemplo n.º 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());
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
   }
 }
Ejemplo n.º 4
0
 public boolean accept(LogEntry entry) {
   entry.setMessage(prefix + entry.getMessage());
   return true;
 }