import static com.google.common.primitives.Longs.tryParse;
import static java.lang.String.format;
import static java.util.logging.Level.WARNING;
+import static java.util.logging.Logger.getLogger;
import java.util.Collection;
import java.util.HashMap;
import net.pterodactylus.sone.main.SonePlugin;
import net.pterodactylus.util.config.Configuration;
import net.pterodactylus.util.config.ConfigurationException;
-import net.pterodactylus.util.logging.Logging;
import net.pterodactylus.util.service.AbstractService;
import net.pterodactylus.util.thread.NamedThreadFactory;
public class Core extends AbstractService implements SoneProvider, PostProvider, PostReplyProvider {
/** The logger. */
- private static final Logger logger = Logging.getLogger(Core.class);
+ private static final Logger logger = getLogger("Sone.Core");
/** The start time. */
private final long startupTime = System.currentTimeMillis();
import static freenet.keys.USK.create;
import static java.lang.String.format;
import static java.util.logging.Level.WARNING;
+import static java.util.logging.Logger.getLogger;
import static net.pterodactylus.sone.freenet.Key.routingKey;
import java.net.MalformedURLException;
import net.pterodactylus.sone.data.Image;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.data.TemporaryImage;
-import net.pterodactylus.util.logging.Logging;
import com.db4o.ObjectContainer;
public class FreenetInterface {
/** The logger. */
- private static final Logger logger = Logging.getLogger(FreenetInterface.class);
+ private static final Logger logger = getLogger("Sone.FreenetInterface");
/** The event bus. */
private final EventBus eventBus;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.logging.Logger.getLogger;
import java.util.Collections;
import java.util.HashMap;
import net.pterodactylus.sone.core.FreenetInterface.InsertToken;
import net.pterodactylus.sone.data.Image;
import net.pterodactylus.sone.data.TemporaryImage;
-import net.pterodactylus.util.logging.Logging;
import com.google.common.base.Function;
public class ImageInserter {
/** The logger. */
- private static final Logger logger = Logging.getLogger(ImageInserter.class);
+ private static final Logger logger = getLogger("Sone.Image.Inserter");
/** The freenet interface. */
private final FreenetInterface freenetInterface;
import static java.lang.String.format;
import static java.lang.System.currentTimeMillis;
import static java.util.concurrent.TimeUnit.DAYS;
+import static java.util.logging.Logger.getLogger;
import java.io.InputStream;
import java.util.HashSet;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.data.Sone.SoneStatus;
import net.pterodactylus.util.io.Closer;
-import net.pterodactylus.util.logging.Logging;
import net.pterodactylus.util.service.AbstractService;
import freenet.client.FetchResult;
public class SoneDownloaderImpl extends AbstractService implements SoneDownloader {
/** The logger. */
- private static final Logger logger = Logging.getLogger(SoneDownloaderImpl.class);
+ private static final Logger logger = getLogger("Sone.Downloader");
/** The maximum protocol version. */
private static final int MAX_PROTOCOL_VERSION = 0;
import static java.lang.String.format;
import static java.lang.System.currentTimeMillis;
+import static java.util.logging.Logger.getLogger;
import static net.pterodactylus.sone.data.Album.NOT_EMPTY;
import java.io.InputStream;
import net.pterodactylus.sone.freenet.StringBucket;
import net.pterodactylus.sone.main.SonePlugin;
import net.pterodactylus.util.io.Closer;
-import net.pterodactylus.util.logging.Logging;
import net.pterodactylus.util.service.AbstractService;
import net.pterodactylus.util.template.HtmlFilter;
import net.pterodactylus.util.template.ReflectionAccessor;
public class SoneInserter extends AbstractService {
/** The logger. */
- private static final Logger logger = Logging.getLogger(SoneInserter.class);
+ private static final Logger logger = getLogger("Sone.Inserter");
/** The insertion delay (in seconds). */
private static final AtomicInteger insertionDelay = new AtomicInteger(60);
package net.pterodactylus.sone.core;
+import static java.util.logging.Logger.getLogger;
+
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import net.pterodactylus.sone.database.PostBuilder;
import net.pterodactylus.sone.database.PostReplyBuilder;
import net.pterodactylus.sone.database.SoneBuilder;
-import net.pterodactylus.util.logging.Logging;
import net.pterodactylus.util.number.Numbers;
import net.pterodactylus.util.xml.SimpleXML;
import net.pterodactylus.util.xml.XML;
*/
public class SoneParser {
- private static final Logger logger = Logging.getLogger(SoneParser.class);
+ private static final Logger logger = getLogger("Sone.Parser");
private static final int MAX_PROTOCOL_VERSION = 0;
private final Core core;
package net.pterodactylus.sone.core;
+import static java.util.logging.Logger.getLogger;
+
import java.net.MalformedURLException;
import java.util.logging.Level;
import java.util.logging.Logger;
-import net.pterodactylus.util.logging.Logging;
import freenet.keys.FreenetURI;
/**
public class SoneUri {
/** The logger. */
- private static final Logger logger = Logging.getLogger(SoneUri.class);
+ private static final Logger logger = getLogger("Sone.Data");
/**
* Generate a Sone URI from the given URI.
package net.pterodactylus.sone.core;
+import static java.util.logging.Logger.getLogger;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import net.pterodactylus.sone.core.event.UpdateFoundEvent;
import net.pterodactylus.sone.main.SonePlugin;
import net.pterodactylus.util.io.Closer;
-import net.pterodactylus.util.logging.Logging;
import net.pterodactylus.util.version.Version;
import com.google.common.eventbus.EventBus;
public class UpdateChecker {
/** The logger. */
- private static final Logger logger = Logging.getLogger(UpdateChecker.class);
+ private static final Logger logger = getLogger("Sone.UpdateChecker");
/** The key of the Sone homepage. */
private static final String SONE_HOMEPAGE = "USK@nwa8lHa271k2QvJ8aa0Ov7IHAV-DFOCFgmDt3X6BpCI,DuQSUZiI~agF8c-6tjsFFGuZ8eICrzWCILB60nT8KKo,AQACAAE/sone/";
package net.pterodactylus.sone.core;
import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.logging.Logger.getLogger;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import net.pterodactylus.sone.freenet.wot.Trust;
import net.pterodactylus.sone.freenet.wot.WebOfTrustConnector;
import net.pterodactylus.sone.freenet.wot.WebOfTrustException;
-import net.pterodactylus.util.logging.Logging;
import net.pterodactylus.util.service.AbstractService;
import com.google.common.annotations.VisibleForTesting;
public class WebOfTrustUpdaterImpl extends AbstractService implements WebOfTrustUpdater {
/** The logger. */
- private static final Logger logger = Logging.getLogger(WebOfTrustUpdaterImpl.class);
+ private static final Logger logger = getLogger("Sone.WoT.Updater");
/** Stop job. */
@SuppressWarnings("synthetic-access")
import static com.google.common.base.Preconditions.checkNotNull;
import static java.lang.String.format;
+import static java.util.logging.Logger.getLogger;
import java.net.MalformedURLException;
import java.util.ArrayList;
import net.pterodactylus.sone.data.SoneOptions.DefaultSoneOptions;
import net.pterodactylus.sone.freenet.wot.Identity;
import net.pterodactylus.sone.freenet.wot.OwnIdentity;
-import net.pterodactylus.util.logging.Logging;
import freenet.keys.FreenetURI;
public class SoneImpl implements Sone {
/** The logger. */
- private static final Logger logger = Logging.getLogger(SoneImpl.class);
+ private static final Logger logger = getLogger("Sone.Data");
/** The ID of this Sone. */
private final String id;
package net.pterodactylus.sone.fcp;
import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.logging.Logger.getLogger;
import java.util.Collections;
import java.util.HashMap;
import net.pterodactylus.sone.freenet.fcp.Command.AccessType;
import net.pterodactylus.sone.freenet.fcp.Command.ErrorResponse;
import net.pterodactylus.sone.freenet.fcp.Command.Response;
-import net.pterodactylus.util.logging.Logging;
import freenet.pluginmanager.FredPluginFCP;
import freenet.pluginmanager.PluginNotFoundException;
}
/** The logger. */
- private static final Logger logger = Logging.getLogger(FcpInterface.class);
+ private static final Logger logger = getLogger("Sone.External.Fcp");
/** Whether the FCP interface is currently active. */
private final AtomicBoolean active = new AtomicBoolean();
package net.pterodactylus.sone.freenet;
+import static java.util.logging.Logger.getLogger;
+
import java.util.logging.Logger;
import net.pterodactylus.util.config.AttributeNotFoundException;
import net.pterodactylus.util.config.Configuration;
import net.pterodactylus.util.config.ConfigurationException;
import net.pterodactylus.util.config.ExtendedConfigurationBackend;
-import net.pterodactylus.util.logging.Logging;
import freenet.client.async.DatabaseDisabledException;
import freenet.pluginmanager.PluginRespirator;
import freenet.pluginmanager.PluginStore;
/** The logger. */
@SuppressWarnings("unused")
- private static final Logger logger = Logging.getLogger(PluginStoreConfigurationBackend.class);
+ private static final Logger logger = getLogger("Sone.Fred");
/** The plugin respirator. */
private final PluginRespirator pluginRespirator;
package net.pterodactylus.sone.freenet.wot;
+import static java.util.logging.Logger.getLogger;
+
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.logging.Logger;
import net.pterodactylus.sone.freenet.plugin.PluginException;
-import net.pterodactylus.util.logging.Logging;
import net.pterodactylus.util.service.AbstractService;
import com.google.common.collect.Sets;
public class IdentityManagerImpl extends AbstractService implements IdentityManager {
/** The logger. */
- private static final Logger logger = Logging.getLogger(IdentityManagerImpl.class);
+ private static final Logger logger = getLogger("Sone.Identities");
/** The event bus. */
private final EventBus eventBus;
package net.pterodactylus.sone.freenet.wot;
+import static java.util.logging.Logger.getLogger;
+
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import net.pterodactylus.sone.freenet.plugin.PluginConnector;
import net.pterodactylus.sone.freenet.plugin.PluginException;
import net.pterodactylus.sone.freenet.plugin.event.ReceivedReplyEvent;
-import net.pterodactylus.util.logging.Logging;
import net.pterodactylus.util.number.Numbers;
import com.google.common.base.Optional;
public class WebOfTrustConnector {
/** The logger. */
- private static final Logger logger = Logging.getLogger(WebOfTrustConnector.class);
+ private static final Logger logger = getLogger("Sone.WoT.Connector");
/** The name of the WoT plugin. */
private static final String WOT_PLUGIN_NAME = "plugins.WebOfTrust.WebOfTrust";
package net.pterodactylus.sone.main;
import static com.google.common.base.Optional.of;
+import static java.util.logging.Logger.getLogger;
import java.io.File;
+import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import net.pterodactylus.util.config.Configuration;
import net.pterodactylus.util.config.ConfigurationException;
import net.pterodactylus.util.config.MapConfigurationBackend;
-import net.pterodactylus.util.logging.Logging;
-import net.pterodactylus.util.logging.LoggingListener;
import net.pterodactylus.util.version.Version;
import com.google.common.base.Optional;
static {
/* initialize logging. */
- Logging.setup("sone");
- Logging.addLoggingListener(new LoggingListener() {
-
+ Logger soneLogger = getLogger("Sone");
+ soneLogger.addHandler(new Handler() {
@Override
- public void logged(LogRecord logRecord) {
- Class<?> loggerClass = Logging.getLoggerClass(logRecord.getLoggerName());
+ public void publish(LogRecord logRecord) {
int recordLevel = logRecord.getLevel().intValue();
if (recordLevel < Level.FINE.intValue()) {
- freenet.support.Logger.debug(loggerClass, logRecord.getMessage(), logRecord.getThrown());
+ freenet.support.Logger.debug(logRecord.getLoggerName(), logRecord.getMessage(), logRecord.getThrown());
} else if (recordLevel < Level.INFO.intValue()) {
- freenet.support.Logger.minor(loggerClass, logRecord.getMessage(), logRecord.getThrown());
+ freenet.support.Logger.minor(logRecord.getLoggerName(), logRecord.getMessage(), logRecord.getThrown());
} else if (recordLevel < Level.WARNING.intValue()) {
- freenet.support.Logger.normal(loggerClass, logRecord.getMessage(), logRecord.getThrown());
+ freenet.support.Logger.normal(logRecord.getLoggerName(), logRecord.getMessage(), logRecord.getThrown());
} else if (recordLevel < Level.SEVERE.intValue()) {
- freenet.support.Logger.warning(loggerClass, logRecord.getMessage(), logRecord.getThrown());
+ freenet.support.Logger.warning(logRecord.getLoggerName(), logRecord.getMessage(), logRecord.getThrown());
} else {
- freenet.support.Logger.error(loggerClass, logRecord.getMessage(), logRecord.getThrown());
+ freenet.support.Logger.error(logRecord.getLoggerName(), logRecord.getMessage(), logRecord.getThrown());
}
}
+
+ @Override
+ public void flush() {
+ }
+
+ @Override
+ public void close() {
+ }
});
}
public static final Version VERSION = new Version(0, 8, 9);
/** The logger. */
- private static final Logger logger = Logging.getLogger(SonePlugin.class);
+ private static final Logger logger = getLogger("Sone.Plugin");
/** The plugin respirator. */
private PluginRespirator pluginRespirator;
/* create the web interface. */
webInterface = injector.getInstance(WebInterface.class);
- boolean startupFailed = true;
- try {
-
- /* start core! */
- core.start();
- webInterface.start();
- webInterface.setFirstStart(firstStart);
- webInterface.setNewConfig(newConfig);
- startupFailed = false;
- } finally {
- if (startupFailed) {
- /*
- * we let the exception bubble up but shut the logging down so
- * that the logfile is not swamped by the installed logging
- * handlers of the failed instances.
- */
- Logging.shutdown();
- }
- }
+ /* start core! */
+ core.start();
+ webInterface.start();
+ webInterface.setFirstStart(firstStart);
+ webInterface.setNewConfig(newConfig);
}
/**
webOfTrustConnector.stop();
} catch (Throwable t1) {
logger.log(Level.SEVERE, "Error while shutting down!", t1);
- } finally {
- /* shutdown logger. */
- Logging.shutdown();
}
}
import static com.google.common.collect.FluentIterable.from;
import static java.util.Arrays.asList;
+import static java.util.logging.Logger.getLogger;
import static net.pterodactylus.sone.data.Album.FLATTENER;
import static net.pterodactylus.sone.data.Album.IMAGES;
import net.pterodactylus.sone.freenet.wot.Trust;
import net.pterodactylus.sone.web.WebInterface;
import net.pterodactylus.sone.web.ajax.GetTimesAjaxPage;
-import net.pterodactylus.util.logging.Logging;
import net.pterodactylus.util.template.Accessor;
import net.pterodactylus.util.template.ReflectionAccessor;
import net.pterodactylus.util.template.TemplateContext;
public class SoneAccessor extends ReflectionAccessor {
/** The logger. */
- private static final Logger logger = Logging.getLogger(SoneAccessor.class);
+ private static final Logger logger = getLogger("Sone.Data");
/** The core. */
private final Core core;
package net.pterodactylus.sone.text;
+import static java.util.logging.Logger.getLogger;
+
import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
import net.pterodactylus.sone.database.PostProvider;
import net.pterodactylus.sone.database.SoneProvider;
import net.pterodactylus.util.io.Closer;
-import net.pterodactylus.util.logging.Logging;
import com.google.common.base.Optional;
public class SoneTextParser implements Parser<SoneTextParserContext> {
/** The logger. */
- private static final Logger logger = Logging.getLogger(SoneTextParser.class);
+ private static final Logger logger = getLogger("Sone.Data.Parser");
/** Pattern to detect whitespace. */
private static final Pattern whitespacePattern = Pattern.compile("[\\u000a\u0020\u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u200c\u200d\u202f\u205f\u2060\u2800\u3000]");
package net.pterodactylus.sone.web;
+import static java.util.logging.Logger.getLogger;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.freenet.wot.OwnIdentity;
import net.pterodactylus.sone.web.page.FreenetRequest;
-import net.pterodactylus.util.logging.Logging;
import net.pterodactylus.util.template.Template;
import net.pterodactylus.util.template.TemplateContext;
import net.pterodactylus.util.web.Method;
public class CreateSonePage extends SoneTemplatePage {
/** The logger. */
- private static final Logger logger = Logging.getLogger(CreateSonePage.class);
+ private static final Logger logger = getLogger("Sone.Web.CreateSone");
/**
* Creates a new “create Sone” page.
package net.pterodactylus.sone.web;
+import static java.util.logging.Logger.getLogger;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.freenet.wot.OwnIdentity;
import net.pterodactylus.sone.web.page.FreenetRequest;
-import net.pterodactylus.util.logging.Logging;
import net.pterodactylus.util.template.Template;
import net.pterodactylus.util.template.TemplateContext;
import net.pterodactylus.util.web.Method;
/** The logger. */
@SuppressWarnings("unused")
- private static final Logger logger = Logging.getLogger(LoginPage.class);
+ private static final Logger logger = getLogger("Sone.Web.Login");
/**
* Creates a new login page.
import static com.google.common.base.Optional.fromNullable;
import static com.google.common.primitives.Ints.tryParse;
+import static java.util.logging.Logger.getLogger;
import java.util.ArrayList;
import java.util.Collection;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.web.page.FreenetRequest;
import net.pterodactylus.util.collection.Pagination;
-import net.pterodactylus.util.logging.Logging;
import net.pterodactylus.util.template.Template;
import net.pterodactylus.util.template.TemplateContext;
import net.pterodactylus.util.text.StringEscaper;
public class SearchPage extends SoneTemplatePage {
/** The logger. */
- private static final Logger logger = Logging.getLogger(SearchPage.class);
+ private static final Logger logger = getLogger("Sone.Web.Search");
/** Short-term cache. */
private final LoadingCache<List<Phrase>, Set<Hit<Post>>> hitCache = CacheBuilder.newBuilder().expireAfterWrite(5, TimeUnit.MINUTES).build(new CacheLoader<List<Phrase>, Set<Hit<Post>>>() {
package net.pterodactylus.sone.web;
+import static java.util.logging.Logger.getLogger;
+
import java.awt.Image;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import net.pterodactylus.sone.text.TextFilter;
import net.pterodactylus.sone.web.page.FreenetRequest;
import net.pterodactylus.util.io.Closer;
-import net.pterodactylus.util.logging.Logging;
import net.pterodactylus.util.template.Template;
import net.pterodactylus.util.template.TemplateContext;
import net.pterodactylus.util.web.Method;
public class UploadImagePage extends SoneTemplatePage {
/** The logger. */
- private static final Logger logger = Logging.getLogger(UploadImagePage.class);
+ private static final Logger logger = getLogger("Sone.Web.UploadImage");
/**
* Creates a new “upload image” page.
package net.pterodactylus.sone.web;
+import static java.util.logging.Logger.getLogger;
import static net.pterodactylus.util.template.TemplateParser.parse;
import java.io.IOException;
import net.pterodactylus.sone.web.page.PageToadlet;
import net.pterodactylus.sone.web.page.PageToadletFactory;
import net.pterodactylus.util.io.Closer;
-import net.pterodactylus.util.logging.Logging;
import net.pterodactylus.util.notify.Notification;
import net.pterodactylus.util.notify.NotificationManager;
import net.pterodactylus.util.notify.TemplateNotification;
public class WebInterface {
/** The logger. */
- private static final Logger logger = Logging.getLogger(WebInterface.class);
+ private static final Logger logger = getLogger("Sone.Web.Main");
/** The notification manager. */
private final NotificationManager notificationManager = new NotificationManager();
package net.pterodactylus.sone.web.ajax;
+import static java.util.logging.Logger.getLogger;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import net.pterodactylus.sone.web.page.FreenetPage;
import net.pterodactylus.sone.web.page.FreenetRequest;
import net.pterodactylus.util.io.Closer;
-import net.pterodactylus.util.logging.Logging;
import net.pterodactylus.util.web.Page;
import net.pterodactylus.util.web.Response;
public abstract class JsonPage implements FreenetPage {
/** The logger. */
- private static final Logger logger = Logging.getLogger(JsonPage.class);
+ private static final Logger logger = getLogger("Sone.Web.Ajax");
/** The JSON serializer. */
private static final ObjectMapper objectMapper = new ObjectMapper();
package net.pterodactylus.sone.web.page;
+import static java.util.logging.Logger.getLogger;
+
import java.io.IOException;
import java.io.StringWriter;
import java.net.URI;
import java.util.logging.Level;
import java.util.logging.Logger;
-import net.pterodactylus.util.logging.Logging;
import net.pterodactylus.util.template.Template;
import net.pterodactylus.util.template.TemplateContext;
import net.pterodactylus.util.template.TemplateContextFactory;
public class FreenetTemplatePage implements FreenetPage, LinkEnabledCallback {
/** The logger. */
- private static final Logger logger = Logging.getLogger(FreenetTemplatePage.class);
+ private static final Logger logger = getLogger("Sone.Web.Freenet");
/** The path of the page. */
private final String path;