+ soneLogger.setUseParentHandlers(false);
+ soneLogger.setLevel(Level.ALL);
+ soneLogger.addHandler(new Handler() {
+ private final LoadingCache<String, Class<?>> classCache = CacheBuilder.newBuilder()
+ .build(new CacheLoader<String, Class<?>>() {
+ @Override
+ public Class<?> load(@Nonnull String key) throws Exception {
+ return SonePlugin.class.getClassLoader().loadClass(key);
+ }
+ });
+
+ @Override
+ public void publish(LogRecord logRecord) {
+ int recordLevel = logRecord.getLevel().intValue();
+ Class<?> loggingClass = classCache.getUnchecked(logRecord.getLoggerName());
+ if (recordLevel < Level.FINE.intValue()) {
+ freenet.support.Logger.debug(loggingClass, logRecord.getMessage(), logRecord.getThrown());
+ } else if (recordLevel < Level.INFO.intValue()) {
+ freenet.support.Logger.minor(loggingClass, logRecord.getMessage(), logRecord.getThrown());
+ } else if (recordLevel < Level.WARNING.intValue()) {
+ freenet.support.Logger.normal(loggingClass, logRecord.getMessage(), logRecord.getThrown());
+ } else if (recordLevel < Level.SEVERE.intValue()) {
+ freenet.support.Logger.warning(loggingClass, logRecord.getMessage(), logRecord.getThrown());
+ } else {
+ freenet.support.Logger.error(loggingClass, logRecord.getMessage(), logRecord.getThrown());
+ }
+ }
+
+ @Override
+ public void flush() {
+ }
+
+ @Override
+ public void close() {
+ }
+ });