]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
(refs #7071) User Logger instead of System.out/err.println
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Mon, 6 Mar 2017 12:50:54 +0000 (14:50 +0200)
committerjsimomaa <jani.simomaa@gmail.com>
Fri, 28 Apr 2017 13:18:33 +0000 (16:18 +0300)
Change-Id: I196a529dd7005367863bb937703f2cd581728cdd

bundles/org.simantics.acorn/src/org/simantics/acorn/GraphClientImpl2.java
bundles/org.simantics.acorn/src/org/simantics/acorn/lru/LRU.java
bundles/org.simantics.db.impl/META-INF/MANIFEST.MF
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/CacheEntryBase.java
bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/RouteGraphUtils.java

index acf8b6e659bfe7de8393b4a046ab32b365bc300d..dce477ebeae0fdf35d1db078acfd7e6e885ea825 100644 (file)
@@ -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);
                                        }
                                }
                        }
index 40dbad0397db0ac83639decc09f9661d022fc3a1..80fec7032940ac3e7a6a1abbebb02325880a8bfc 100644 (file)
@@ -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<MapKey,MapValue extends LRUObject<MapKey, MapValue>> {
-       
+
+    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<MapKey,MapValue extends LRUObject<MapKey, MapValue>> {
                            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<MapKey,MapValue extends LRUObject<MapKey, MapValue>> {
                         runWithMutex();
                         done = true;
                     } else {
-                        System.err.println("Retry mutex acquire");
+                        LOGGER.warn("Retry mutex acquire");
                         gotMutex = impl.tryAcquireMutex();
                     }
 
index 561843e20dc76e83c95f8ae16dfa5072c35c6f6b..4b8c3cbad87dd015fe7f358eac8bdc088480d85a 100644 (file)
@@ -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,
index 31b585aaeeccd43cb2089ebe254d680c314a709b..5776857d330ad98374d9b8c07d575ddb0118f7b2 100644 (file)
@@ -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;
     }
index de99bd25fb8c626d7ca080161f77e0581681730b..99d9acb705388a6b85f242ec5485c08d1dcdc208 100644 (file)
@@ -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);