use of org.apache.log4j.spi.ThrowableInformation in project jbosstools-hibernate by jbosstools.
the class PluginLogAppender method append.
/**
* Log event happened.
* Translates level to status instance codes:
* level > Level.ERROR - Status.ERROR
* level > Level.WARN - Status.WARNING
* level > Level.DEBUG - Status.INFO
* default - Status.OK
* @param event LoggingEvent instance
*/
public void append(LoggingEvent event) {
if (this.layout == null) {
this.errorHandler.error(ConsoleMessages.PluginLogAppender_missing_layout_for_appender + this.name, null, ErrorCode.MISSING_LAYOUT);
return;
}
String text = this.layout.format(event);
Throwable thrown = null;
if (this.layout.ignoresThrowable()) {
ThrowableInformation info = event.getThrowableInformation();
if (info != null)
thrown = info.getThrowable();
}
/*
Level level = event.getLevel();
int severity = IStatus.OK;
if (level.toInt() >= Priority.ERROR_INT)
severity = IStatus.ERROR;
else
if (level.toInt() >= Priority.WARN_INT)
severity = IStatus.WARNING;
else
if (level.toInt() >= Priority.DEBUG_INT)
severity = IStatus.INFO;
this.pluginLog.log(new Status(severity,
this.pluginLog.getBundle().getSymbolicName(),
level.toInt(),text,thrown));*/
Object peek = CurrentContext.peek();
MessageConsoleStream stream = KnownConfigurations.getInstance().findLoggingStream((String) peek);
if (stream != null) {
stream.println(text);
if (thrown != null) {
StringWriter stringWriter = new StringWriter();
thrown.printStackTrace(new PrintWriter(stringWriter));
stream.println(stringWriter.getBuffer().toString());
}
}
}
Aggregations