From: Hannu Niemistö Date: Mon, 6 Mar 2017 12:50:54 +0000 (+0200) Subject: (refs #7071) User Logger instead of System.out/err.println X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=c5622db70b5ec3b5929f3b0e0fa4a56d60f3343c;p=simantics%2Fplatform.git (refs #7071) User Logger instead of System.out/err.println Change-Id: I196a529dd7005367863bb937703f2cd581728cdd --- diff --git a/bundles/org.simantics.acorn/src/org/simantics/acorn/GraphClientImpl2.java b/bundles/org.simantics.acorn/src/org/simantics/acorn/GraphClientImpl2.java index acf8b6e65..dce477ebe 100644 --- a/bundles/org.simantics.acorn/src/org/simantics/acorn/GraphClientImpl2.java +++ b/bundles/org.simantics.acorn/src/org/simantics/acorn/GraphClientImpl2.java @@ -27,14 +27,13 @@ import org.simantics.acorn.exception.IllegalAcornStateException; import org.simantics.acorn.internal.ClusterChange; import org.simantics.acorn.internal.ClusterUpdateProcessorBase; import org.simantics.acorn.internal.UndoClusterUpdateProcessor; +import org.simantics.acorn.lru.ClusterChangeSet.Entry; import org.simantics.acorn.lru.ClusterInfo; import org.simantics.acorn.lru.ClusterStreamChunk; import org.simantics.acorn.lru.ClusterUpdateOperation; -import org.simantics.acorn.lru.ClusterChangeSet.Entry; import org.simantics.db.ClusterCreator; import org.simantics.db.Database; import org.simantics.db.ServiceLocator; -import org.simantics.db.common.utils.Logger; import org.simantics.db.exception.DatabaseException; import org.simantics.db.exception.SDBException; import org.simantics.db.server.ProCoreException; @@ -43,11 +42,14 @@ import org.simantics.db.service.ClusterUID; import org.simantics.db.service.LifecycleSupport; import org.simantics.utils.datastructures.Pair; import org.simantics.utils.logging.TimeLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import gnu.trove.map.hash.TLongObjectHashMap; public class GraphClientImpl2 implements Database.Session { - + + private static final Logger LOGGER = LoggerFactory.getLogger(GraphClientImpl2.class); public static final boolean DEBUG = false; public final ClusterManager clusters; @@ -124,10 +126,10 @@ public class GraphClientImpl2 implements Database.Session { mainProgram.mutex.release(); } } catch (IllegalAcornStateException | ProCoreException e) { - Logger.defaultLogError("Snapshotting failed", e); + LOGGER.error("Snapshotting failed", e); unexpectedClose = true; } catch (InterruptedException e) { - Logger.defaultLogError("Snapshotting interrupted", e); + LOGGER.error("Snapshotting interrupted", e); } finally { try { if(tr != null) @@ -137,11 +139,11 @@ public class GraphClientImpl2 implements Database.Session { try { support.close(); } catch (DatabaseException e1) { - Logger.defaultLogError("Failed to close database as a safety measure due to failed snapshotting", e1); + LOGGER.error("Failed to close database as a safety measure due to failed snapshotting", e1); } } } catch (ProCoreException e) { - Logger.defaultLogError("Failed to end snapshotting write transaction", e); + LOGGER.error("Failed to end snapshotting write transaction", e); } } } @@ -184,7 +186,7 @@ public class GraphClientImpl2 implements Database.Session { @Override public void close() throws ProCoreException { - System.err.println("Closing " + this + " and mainProgram " + mainProgram); + LOGGER.info("Closing " + this + " and mainProgram " + mainProgram); if(!closed && !isClosing) { isClosing = true; try { @@ -249,7 +251,7 @@ public class GraphClientImpl2 implements Database.Session { clusters.state.headChangeSetId++; return clusters.state.headChangeSetId; } catch (SDBException e) { - Logger.defaultLogError("Failed to undo cancelled transaction", e); + LOGGER.error("Failed to undo cancelled transaction", e); throw new ProCoreException(e); } } @@ -758,10 +760,10 @@ public class GraphClientImpl2 implements Database.Session { mainProgram.mutex.release(); } } catch (IllegalAcornStateException | ProCoreException e) { - Logger.defaultLogError("Purge failed", e); + LOGGER.error("Purge failed", e); unexpectedClose = true; } catch (InterruptedException e) { - Logger.defaultLogError("Purge interrupted", e); + LOGGER.error("Purge interrupted", e); } finally { try { if(tr != null) @@ -771,11 +773,11 @@ public class GraphClientImpl2 implements Database.Session { try { support.close(); } catch (DatabaseException e1) { - Logger.defaultLogError("Failed to close database as a safety measure due to failed purge", e1); + LOGGER.error("Failed to close database as a safety measure due to failed purge", e1); } } } catch (ProCoreException e) { - Logger.defaultLogError("Failed to end purge write transaction", e); + LOGGER.error("Failed to end purge write transaction", e); } } } diff --git a/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/LRU.java b/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/LRU.java index 40dbad039..80fec7032 100644 --- a/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/LRU.java +++ b/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/LRU.java @@ -16,16 +16,19 @@ import org.simantics.acorn.ClusterManager; import org.simantics.acorn.GraphClientImpl2; import org.simantics.acorn.exception.AcornAccessVerificationException; import org.simantics.acorn.exception.IllegalAcornStateException; -import org.simantics.db.common.utils.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /* * The order rule of synchronization for LRU and LRUObject is: - * § Always lock LRUObject first! + * � Always lock LRUObject first! * */ public class LRU> { - + + private static final Logger LOGGER = LoggerFactory.getLogger(LRU.class); + public static boolean VERIFY = true; final private long swapTime = 5L*1000000000L; @@ -519,7 +522,7 @@ public class LRU> { manager.notSafeToMakeSnapshot(new IllegalAcornStateException(t)); } t.printStackTrace(); - Logger.defaultLogError(t); + LOGGER.error("Exception happened in WriteRunnable.run", t); } } @@ -559,7 +562,7 @@ public class LRU> { runWithMutex(); done = true; } else { - System.err.println("Retry mutex acquire"); + LOGGER.warn("Retry mutex acquire"); gotMutex = impl.tryAcquireMutex(); } diff --git a/bundles/org.simantics.db.impl/META-INF/MANIFEST.MF b/bundles/org.simantics.db.impl/META-INF/MANIFEST.MF index 561843e20..4b8c3cbad 100644 --- a/bundles/org.simantics.db.impl/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.db.impl/META-INF/MANIFEST.MF @@ -6,7 +6,8 @@ Bundle-Version: 1.1.0.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Require-Bundle: org.simantics.db.common;bundle-version="0.8.0", org.eclipse.core.runtime;bundle-version="3.6.0", - gnu.trove3;bundle-version="3.0.0" + gnu.trove3;bundle-version="3.0.0", + org.slf4j.api Export-Package: org.simantics.db.impl, org.simantics.db.impl.exception, org.simantics.db.impl.graph, diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/CacheEntryBase.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/CacheEntryBase.java index 31b585aae..5776857d3 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/CacheEntryBase.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/CacheEntryBase.java @@ -14,14 +14,17 @@ package org.simantics.db.impl.query; import java.util.ArrayList; import java.util.Iterator; -import org.simantics.db.common.utils.Logger; import org.simantics.db.exception.DatabaseException; import org.simantics.db.impl.DebugPolicy; import org.simantics.db.impl.graph.ReadGraphImpl; import org.simantics.db.impl.procedure.InternalProcedure; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; abstract public class CacheEntryBase extends CacheEntry { + private static final Logger LOGGER = LoggerFactory.getLogger(CacheEntryBase.class); + // Default level is something that is not quite a prospect but still allows for ordering within CacheCollectionResult public static final short UNDEFINED_LEVEL = 5; @@ -108,7 +111,7 @@ abstract public class CacheEntryBase extends CacheEntry { statusOrException = EXCEPTED; result = t; } else { - Logger.defaultLogError("Cache entry got excepted status after being discarded: " + getClass().getSimpleName(), t); + LOGGER.warn("Cache entry got excepted status after being discarded: " + getClass().getSimpleName(), t); result = t; } } @@ -139,7 +142,7 @@ abstract public class CacheEntryBase extends CacheEntry { final public boolean assertPending() { boolean result = isPending(); if(!result) { - System.err.println("Assertion failed, expected pending, got " + statusOrException); + LOGGER.warn("Assertion failed, expected pending, got " + statusOrException); } return result; } diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/RouteGraphUtils.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/RouteGraphUtils.java index de99bd25f..99d9acb70 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/RouteGraphUtils.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/RouteGraphUtils.java @@ -69,12 +69,15 @@ import org.simantics.structural2.modelingRules.CPTerminal; import org.simantics.structural2.modelingRules.IAttachmentRelationMap; import org.simantics.structural2.modelingRules.IModelingRules; import org.simantics.utils.threads.CurrentThread; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; public class RouteGraphUtils { + private static final Logger LOGGER = LoggerFactory.getLogger(RouteGraph.class); public static boolean DEBUG = false; public static final ILineEndStyle HEAD = new ArrowLineEndStyle("fill 2 1 0"); @@ -341,7 +344,7 @@ public class RouteGraphUtils { RouteNode n1 = nodeByData.get(link.first()); RouteNode n2 = nodeByData.get(link.second()); if (n1 == null || n2 == null) { - System.err.println("Stray connection link found: " + link.toString(graph)); + LOGGER.warn("Stray connection link found: " + link.toString(graph)); continue; } rg.link(n1, n2);