@Test public void testAppend() { final UnifiedSystemLogAppender a = new UnifiedSystemLogAppender(); a.setLayout(new SimpleLayout()); a.append(new LoggingEvent("f", Logger.getLogger(UnifiedSystemLogAppender.class), Level.DEBUG, "Test", new RuntimeException())); a.append(new LoggingEvent("f", Logger.getLogger(UnifiedSystemLogAppender.class), Level.ERROR, "Test", new RuntimeException())); }
@Override protected void append(final LoggingEvent event) { if(null == event.getMessage()) { return; } final String logger = String.format("%s %s", event.getThreadName(), event.getLogger().getName()); switch(event.getLevel().toInt()) { case Level.FATAL_INT: case Level.ERROR_INT: this.log(OS_LOG_TYPE_ERROR, logger, event.getMessage().toString()); break; case Level.TRACE_INT: this.log(OS_LOG_TYPE_DEBUG, logger, event.getMessage().toString()); break; case Level.DEBUG_INT: case Level.INFO_INT: this.log(OS_LOG_TYPE_INFO, logger, event.getMessage().toString()); break; case Level.WARN_INT: default: this.log(OS_LOG_TYPE_DEFAULT, logger, event.getMessage().toString()); break; } if(layout.ignoresThrowable()) { final String[] trace = event.getThrowableStrRep(); if(trace != null) { for(final String t : trace) { this.log(OS_LOG_TYPE_DEFAULT, logger, t); } } } }
UnifiedSystemLogAppender extends AppenderSkeleton { @Override protected void append(final LoggingEvent event) { if(null == event.getMessage()) { return; } final String logger = String.format("%s %s", event.getThreadName(), event.getLogger().getName()); switch(event.getLevel().toInt()) { case Level.FATAL_INT: case Level.ERROR_INT: this.log(OS_LOG_TYPE_ERROR, logger, event.getMessage().toString()); break; case Level.TRACE_INT: this.log(OS_LOG_TYPE_DEBUG, logger, event.getMessage().toString()); break; case Level.DEBUG_INT: case Level.INFO_INT: this.log(OS_LOG_TYPE_INFO, logger, event.getMessage().toString()); break; case Level.WARN_INT: default: this.log(OS_LOG_TYPE_DEFAULT, logger, event.getMessage().toString()); break; } if(layout.ignoresThrowable()) { final String[] trace = event.getThrowableStrRep(); if(trace != null) { for(final String t : trace) { this.log(OS_LOG_TYPE_DEFAULT, logger, t); } } } } }
UnifiedSystemLogAppender extends AppenderSkeleton { @Override protected void append(final LoggingEvent event) { if(null == event.getMessage()) { return; } final String logger = String.format("%s %s", event.getThreadName(), event.getLogger().getName()); switch(event.getLevel().toInt()) { case Level.FATAL_INT: case Level.ERROR_INT: this.log(OS_LOG_TYPE_ERROR, logger, event.getMessage().toString()); break; case Level.TRACE_INT: this.log(OS_LOG_TYPE_DEBUG, logger, event.getMessage().toString()); break; case Level.DEBUG_INT: case Level.INFO_INT: this.log(OS_LOG_TYPE_INFO, logger, event.getMessage().toString()); break; case Level.WARN_INT: default: this.log(OS_LOG_TYPE_DEFAULT, logger, event.getMessage().toString()); break; } if(layout.ignoresThrowable()) { final String[] trace = event.getThrowableStrRep(); if(trace != null) { for(final String t : trace) { this.log(OS_LOG_TYPE_DEFAULT, logger, t); } } } }  }
UnifiedSystemLogAppender extends AppenderSkeleton { @Override protected void append(final LoggingEvent event) { if(null == event.getMessage()) { return; } final String logger = String.format("%s %s", event.getThreadName(), event.getLogger().getName()); switch(event.getLevel().toInt()) { case Level.FATAL_INT: case Level.ERROR_INT: this.log(OS_LOG_TYPE_ERROR, logger, event.getMessage().toString()); break; case Level.TRACE_INT: this.log(OS_LOG_TYPE_DEBUG, logger, event.getMessage().toString()); break; case Level.DEBUG_INT: case Level.INFO_INT: this.log(OS_LOG_TYPE_INFO, logger, event.getMessage().toString()); break; case Level.WARN_INT: default: this.log(OS_LOG_TYPE_DEFAULT, logger, event.getMessage().toString()); break; } if(layout.ignoresThrowable()) { final String[] trace = event.getThrowableStrRep(); if(trace != null) { for(final String t : trace) { this.log(OS_LOG_TYPE_DEFAULT, logger, t); } } } }  native void log(int type, String category, String message); @Override void close(); @Override boolean requiresLayout(); }
UnifiedSystemLogAppender extends AppenderSkeleton { @Override protected void append(final LoggingEvent event) { if(null == event.getMessage()) { return; } final String logger = String.format("%s %s", event.getThreadName(), event.getLogger().getName()); switch(event.getLevel().toInt()) { case Level.FATAL_INT: case Level.ERROR_INT: this.log(OS_LOG_TYPE_ERROR, logger, event.getMessage().toString()); break; case Level.TRACE_INT: this.log(OS_LOG_TYPE_DEBUG, logger, event.getMessage().toString()); break; case Level.DEBUG_INT: case Level.INFO_INT: this.log(OS_LOG_TYPE_INFO, logger, event.getMessage().toString()); break; case Level.WARN_INT: default: this.log(OS_LOG_TYPE_DEFAULT, logger, event.getMessage().toString()); break; } if(layout.ignoresThrowable()) { final String[] trace = event.getThrowableStrRep(); if(trace != null) { for(final String t : trace) { this.log(OS_LOG_TYPE_DEFAULT, logger, t); } } } }  native void log(int type, String category, String message); @Override void close(); @Override boolean requiresLayout(); static final int OS_LOG_TYPE_DEFAULT; static final int OS_LOG_TYPE_INFO; static final int OS_LOG_TYPE_DEBUG; static final int OS_LOG_TYPE_ERROR; static final int OS_LOG_TYPE_FAULT; }