use of org.eclipse.osgi.framework.log.FrameworkLogEntry in project rt.equinox.framework by eclipse.
the class EquinoxLogFactory method createFrameworkLog.
FrameworkLog createFrameworkLog(Bundle bundle, EquinoxLogWriter eclipseWriter) {
final EquinoxLogWriter logWriter = eclipseWriter == null ? defaultWriter : eclipseWriter;
final Logger logger = bundle == null ? logManager.getSystemBundleLog().getLogger(eclipseWriter.getLoggerName()) : logManager.getSystemBundleLog().getLogger(bundle, logWriter.getLoggerName());
return new FrameworkLog() {
public void setWriter(Writer newWriter, boolean append) {
logWriter.setWriter(newWriter, append);
}
public void setFile(File newFile, boolean append) throws IOException {
logWriter.setFile(newFile, append);
}
public void setConsoleLog(boolean consoleLog) {
logWriter.setConsoleLog(consoleLog);
}
public void log(FrameworkLogEntry logEntry) {
logger.log(logEntry, convertLevel(logEntry), logEntry.getMessage(), logEntry.getThrowable());
}
public void log(FrameworkEvent frameworkEvent) {
Bundle b = frameworkEvent.getBundle();
Throwable t = frameworkEvent.getThrowable();
String entry = b.getSymbolicName() == null ? b.getLocation() : b.getSymbolicName();
int severity;
switch(frameworkEvent.getType()) {
case FrameworkEvent.INFO:
severity = FrameworkLogEntry.INFO;
break;
case FrameworkEvent.ERROR:
severity = FrameworkLogEntry.ERROR;
break;
case FrameworkEvent.WARNING:
severity = FrameworkLogEntry.WARNING;
break;
default:
severity = FrameworkLogEntry.OK;
}
// $NON-NLS-1$
FrameworkLogEntry logEntry = new FrameworkLogEntry(entry, severity, 0, "", 0, t, null);
log(logEntry);
}
public File getFile() {
return logWriter.getFile();
}
public void close() {
logWriter.close();
}
};
}
Aggregations