package org.argeo.cms.internal.kernel;
import java.io.IOException;
+import java.net.URI;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.argeo.node.ArgeoLogger;
import org.argeo.node.NodeConstants;
import org.argeo.osgi.useradmin.UserAdminConf;
+import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
import org.osgi.service.cm.ConfigurationAdmin;
import org.osgi.service.log.LogEntry;
+import org.osgi.service.log.LogLevel;
import org.osgi.service.log.LogListener;
import org.osgi.service.log.LogReaderService;
-import org.osgi.service.log.LogService;
/** Not meant to be used directly in standard log4j config */
class NodeLogger implements ArgeoLogger, LogListener {
}
};
- @SuppressWarnings("unchecked")
public NodeLogger(LogReaderService lrs) {
Enumeration<LogEntry> logEntries = lrs.getLog();
while (logEntries.hasMoreElements())
log4jConfiguration = log4jConfiguration.substring("file:".length());
}
try {
- Path log4jconfigPath = Paths.get(log4jConfiguration);
+ Path log4jconfigPath;
+ if (log4jConfiguration.startsWith("file:"))
+ log4jconfigPath = Paths.get(new URI(log4jConfiguration));
+ else
+ log4jconfigPath = Paths.get(log4jConfiguration);
Thread log4jConfWatcher = new Log4jConfWatcherThread(log4jconfigPath);
log4jConfWatcher.start();
} catch (Exception e) {
@Override
public void logged(LogEntry status) {
Log pluginLog = LogFactory.getLog(status.getBundle().getSymbolicName());
- Integer severity = status.getLevel();
- if (severity == LogService.LOG_ERROR) {
+ LogLevel severity = status.getLogLevel();
+ if (severity.equals(LogLevel.ERROR) && pluginLog.isErrorEnabled()) {
// FIXME Fix Argeo TP
if (status.getException() instanceof SignatureException)
return;
pluginLog.error(msg(status), status.getException());
- } else if (severity == LogService.LOG_WARNING)
- pluginLog.warn(msg(status), status.getException());
- else if (severity == LogService.LOG_INFO && pluginLog.isDebugEnabled())
+ } else if (severity.equals(LogLevel.WARN) && pluginLog.isWarnEnabled()) {
+ if (pluginLog.isTraceEnabled())
+ pluginLog.warn(msg(status), status.getException());
+ else
+ pluginLog.warn(msg(status));
+ } else if (severity.equals(LogLevel.INFO) && pluginLog.isDebugEnabled())
pluginLog.debug(msg(status), status.getException());
- else if (severity == LogService.LOG_DEBUG && pluginLog.isTraceEnabled())
+ else if (severity.equals(LogLevel.DEBUG) && pluginLog.isTraceEnabled())
+ pluginLog.trace(msg(status), status.getException());
+ else if (severity.equals(LogLevel.TRACE) && pluginLog.isTraceEnabled())
pluginLog.trace(msg(status), status.getException());
}
private String msg(LogEntry status) {
StringBuilder sb = new StringBuilder();
sb.append(status.getMessage());
+ Bundle bundle = status.getBundle();
+ if (bundle != null) {
+ sb.append(" '" + bundle.getSymbolicName() + "'");
+ }
ServiceReference<?> sr = status.getServiceReference();
if (sr != null) {
sb.append(' ');