From: David ‘Bombe’ Roden Date: Thu, 12 Jun 2008 08:33:17 +0000 (+0200) Subject: add logging X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=fe1254de274c0e3b74df93d00051e7025d725579;p=jSite2.git add logging --- diff --git a/src/net/pterodactylus/jsite/core/CoreImpl.java b/src/net/pterodactylus/jsite/core/CoreImpl.java index cd65bf4..2296e22 100644 --- a/src/net/pterodactylus/jsite/core/CoreImpl.java +++ b/src/net/pterodactylus/jsite/core/CoreImpl.java @@ -25,7 +25,10 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.Executor; import java.util.concurrent.Executors; +import java.util.logging.Level; +import java.util.logging.Logger; +import net.pterodactylus.util.logging.Logging; /** * The core of jSite. @@ -34,6 +37,9 @@ import java.util.concurrent.Executors; */ public class CoreImpl implements Core, NodeListener, RequestListener { + /** The logger. */ + private static final Logger logger = Logging.getLogger(CoreImpl.class.getName()); + /** The core listeners. */ private final List coreListeners = new ArrayList(); @@ -59,6 +65,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * {@inheritDoc} */ public void addCoreListener(CoreListener coreListener) { + logger.log(Level.FINEST, "adding core listener: " + coreListener); coreListeners.add(coreListener); } @@ -66,6 +73,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * {@inheritDoc} */ public void removeCoreListener(CoreListener coreListener) { + logger.log(Level.FINEST, "removing core listener: " + coreListener); coreListeners.remove(coreListener); } @@ -76,6 +84,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * The directory the projects were loaded from */ private void fireLoadingProjectsDone(String directory) { + logger.log(Level.FINEST, "firing loadingProjectsDone event with [directory=" + directory + "]"); for (CoreListener coreListener : coreListeners) { coreListener.loadingProjectsDone(directory); } @@ -91,6 +100,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * The exception that occured when loading projects */ private void fireLoadingProjectsFailed(String directory, Throwable throwable) { + logger.log(Level.FINEST, "firing loadingProjectsFailed event with [directory=" + directory + ",throwable=" + throwable + "]"); for (CoreListener coreListener : coreListeners) { coreListener.loadingProjectsFailed(directory, throwable); } @@ -103,6 +113,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * The directory the projects were saved to */ private void fireSavingProjectsDone(String directory) { + logger.log(Level.FINEST, "firing savingProjectsDone event with [directory=" + directory + "]"); for (CoreListener coreListener : coreListeners) { coreListener.savingProjectsDone(directory); } @@ -117,6 +128,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * The exception that occured when saving the projects */ private void fireSavingProjectsFailed(String directory, Throwable throwable) { + logger.log(Level.FINEST, "firing savingProjectsFailed event with [directory=" + directory + ",throwable=" + throwable + "]"); for (CoreListener coreListener : coreListeners) { coreListener.savingProjectsFailed(directory, throwable); } @@ -129,6 +141,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * The project that was added */ private void fireProjectAdded(Project project) { + logger.log(Level.FINEST, "firing projectAdded event with [project=" + project + "]"); for (CoreListener coreListener : coreListeners) { coreListener.projectAdded(project); } @@ -143,6 +156,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * The clone of the project */ private void fireProjectCloned(Project clonedProject, Project projectClone) { + logger.log(Level.FINEST, "firing projectCloned event with [clonedProject=" + clonedProject + ",projectClone=" + projectClone + "]"); for (CoreListener coreListener : coreListeners) { coreListener.projectCloned(clonedProject, projectClone); } @@ -155,6 +169,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * The project that was removed */ private void fireProjectRemoved(Project project) { + logger.log(Level.FINEST, "firing projectRemoved event with [project=" + project + "]"); for (CoreListener coreListener : coreListeners) { coreListener.projectRemoved(project); } @@ -167,6 +182,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * The directory the nodes were loaded from */ private void fireLoadingNodesDone(String directory) { + logger.log(Level.FINEST, "firing loadingNodesDone event with [directory=" + directory + "]"); for (CoreListener coreListener : coreListeners) { coreListener.loadingNodesDone(directory); } @@ -181,6 +197,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * The exception that occured while loading the nodes */ private void fireLoadingNodesFailed(String directory, Throwable throwable) { + logger.log(Level.FINEST, "firing loadingNodesFailed event with [directory=" + directory + ",throwable=" + throwable + "]"); for (CoreListener coreListener : coreListeners) { coreListener.loadingNodesFailed(directory, throwable); } @@ -193,6 +210,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * The directory the nodes were saved to */ private void fireSavingNodesDone(String directory) { + logger.log(Level.FINEST, "firing savingNodesDone event with [directory=" + directory + "]"); for (CoreListener coreListener : coreListeners) { coreListener.savingNodesDone(directory); } @@ -207,6 +225,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * The exception that occured while saving the nodes */ private void fireSavingNodesFailed(String directory, Throwable throwable) { + logger.log(Level.FINEST, "firing savingNodesFailed event with [directory=" + directory + ",throwable=" + throwable + "]"); for (CoreListener coreListener : coreListeners) { coreListener.savingProjectsFailed(directory, throwable); } @@ -216,6 +235,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * Notifies all core listeners that the core has loaded and is ready to run. */ private void fireCoreLoaded() { + logger.log(Level.FINEST, "firing coreLoaded event"); for (CoreListener coreListener : coreListeners) { coreListener.coreLoaded(); } @@ -225,6 +245,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * Notifies all listeners that the core was stopped. */ private void fireCoreStopped() { + logger.log(Level.FINEST, "firing coreStopped event"); for (CoreListener coreListener : coreListeners) { coreListener.coreStopped(); } @@ -237,6 +258,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * The node that was added */ private void fireNodeAdded(Node node) { + logger.log(Level.FINEST, "firing nodeAdded event with [node=" + node + "]"); for (CoreListener coreListener : coreListeners) { coreListener.nodeAdded(node); } @@ -249,6 +271,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * The node that was removed */ private void fireNodeRemoved(Node node) { + logger.log(Level.FINEST, "firing nodeRemoved event with [node=" + node + "]"); for (CoreListener coreListener : coreListeners) { coreListener.nodeRemoved(node); } @@ -262,6 +285,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * The node that is being connected to */ private void fireNodeConnecting(Node node) { + logger.log(Level.FINEST, "firing nodeConnecting event with [node=" + node + "]"); for (CoreListener coreListener : coreListeners) { coreListener.nodeConnecting(node); } @@ -274,6 +298,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * The node that is now connected */ private void fireNodeConnected(Node node) { + logger.log(Level.FINEST, "firing nodeConnected event with [node=" + node + "]"); for (CoreListener coreListener : coreListeners) { coreListener.nodeConnected(node); } @@ -288,6 +313,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * The cause of the failure */ private void fireNodeConnectionFailed(Node node, Throwable cause) { + logger.log(Level.FINEST, "firing nodeConnectionFailed event with [node=" + node + ",cause=" + cause + "]"); for (CoreListener coreListener : coreListeners) { coreListener.nodeConnectionFailed(node, cause); } @@ -303,6 +329,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * if there was no exception */ private void fireNodeDisconnected(Node node, Throwable throwable) { + logger.log(Level.FINEST, "firing nodeDisconnected event with [node=" + node + ",throwable=" + throwable + "]"); for (CoreListener coreListener : coreListeners) { coreListener.nodeDisconnected(node, throwable); } @@ -396,6 +423,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * {@inheritDoc} */ public void start() { + logger.log(Level.INFO, "starting core…"); try { nodeManager.load(); fireLoadingNodesDone(nodeManager.getDirectory()); @@ -415,6 +443,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * {@inheritDoc} */ public void stop() { + logger.log(Level.INFO, "stopping core…"); try { projectManager.save(); fireSavingProjectsDone(projectManager.getDirectory()); @@ -434,6 +463,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * {@inheritDoc} */ public boolean addNode(Node node) throws UnknownHostException { + logger.log(Level.INFO, "addNode(node=" + node + ")"); return nodeManager.addNode(node); } @@ -441,6 +471,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * {@inheritDoc} */ public void removeNode(Node node) { + logger.log(Level.INFO, "removeNode(node=" + node + ")"); nodeManager.removeNode(node); } @@ -448,6 +479,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * {@inheritDoc} */ public void connectToNode(Node node) { + logger.log(Level.INFO, "connectToNode(node=" + node + ")"); fireNodeConnecting(node); nodeManager.connect(node); } @@ -456,6 +488,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * {@inheritDoc} */ public void disconnectFromNode(Node node) { + logger.log(Level.INFO, "disconnectFromNode(node=" + node + ")"); nodeManager.disconnect(node); } @@ -463,6 +496,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * {@inheritDoc} */ public void createProject() throws IOException, JSiteException { + logger.log(Level.INFO, "createProject()"); Project newProject = projectManager.createProject(); fireProjectAdded(newProject); } @@ -471,6 +505,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * {@inheritDoc} */ public void cloneProject(Project project) { + logger.log(Level.INFO, "cloneProject(project=" + project + ")"); Project projectClone = projectManager.cloneProject(project); fireProjectCloned(project, projectClone); } @@ -479,6 +514,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { * {@inheritDoc} */ public void removeProject(Project project) { + logger.log(Level.INFO, "removeProject(project=" + project + ")"); projectManager.removeProject(project); fireProjectRemoved(project); } @@ -492,6 +528,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { */ @SuppressWarnings("unused") private void loadConfig() { + logger.log(Level.INFO, "loadConfig()"); /* TODO */ } @@ -500,6 +537,7 @@ public class CoreImpl implements Core, NodeListener, RequestListener { */ @SuppressWarnings("unused") private void saveConfig() { + logger.log(Level.INFO, "saveConfig()"); /* TODO */ }