]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Utilize slf4j 93/93/1
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Mon, 26 Sep 2016 06:08:29 +0000 (09:08 +0300)
committerHannu Niemistö <hannu.niemisto@semantum.fi>
Mon, 26 Sep 2016 06:58:44 +0000 (09:58 +0300)
Changed System.out/err prints to use logging in several places. Removed
org.simantics.Logging and replaced all uses by slf4j.

Change-Id: Ib0a9f4f87b945fd59130a9dfd02fe02d39ee0eac

41 files changed:
bundles/org.simantics.annotation.ui/META-INF/MANIFEST.MF
bundles/org.simantics.annotation.ui/src/org/simantics/annotation/ui/SCL.java
bundles/org.simantics.db.common/META-INF/MANIFEST.MF
bundles/org.simantics.db.common/src/org/simantics/db/common/request/PropertyMapOfResource.java
bundles/org.simantics.db.common/src/org/simantics/db/common/uri/EscapedChildMapOfResource.java
bundles/org.simantics.db.common/src/org/simantics/db/common/uri/UnescapedChildMapOfResource.java
bundles/org.simantics.document.server/META-INF/MANIFEST.MF
bundles/org.simantics.document.server/src/org/simantics/document/server/DocumentHistoryListener.java
bundles/org.simantics.document.server/src/org/simantics/document/server/request/NodeRequestUtils.java
bundles/org.simantics.export.core/META-INF/MANIFEST.MF
bundles/org.simantics.export.core/src/org/simantics/export/core/pdf/ServiceBasedPdfExportPageEvent.java
bundles/org.simantics.help.ui/META-INF/MANIFEST.MF
bundles/org.simantics.help.ui/src/org/simantics/help/ui/OpenHelpFileAdapter.java
bundles/org.simantics.issues.common/META-INF/MANIFEST.MF
bundles/org.simantics.issues.common/src/org/simantics/issues/common/DependencyIssueValidator2.java
bundles/org.simantics.issues.common/src/org/simantics/issues/common/IssueUtils.java
bundles/org.simantics.modeling.ui/META-INF/MANIFEST.MF
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/ModeledActions.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/ConfigurationPropertiesSection.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/OpenSheetAdapter.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/PopulateElementMonitorDropParticipant.java
bundles/org.simantics.modeling/META-INF/MANIFEST.MF
bundles/org.simantics.modeling/src/org/simantics/modeling/SCL.java
bundles/org.simantics.modeling/src/org/simantics/modeling/scl/SCLRealm.java
bundles/org.simantics.modeling/src/org/simantics/modeling/typicals/SyncTypicalTemplatesToInstances.java
bundles/org.simantics.project/META-INF/MANIFEST.MF
bundles/org.simantics.project/src/org/simantics/project/management/ServerManager.java
bundles/org.simantics.project/src/org/simantics/project/management/ServerManagerFactory.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/Expression.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/relations/TransitiveClosureRelation.java
bundles/org.simantics.scl.runtime/META-INF/MANIFEST.MF
bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/reporting/SCLReportingHandler.java
bundles/org.simantics.selectionview/META-INF/MANIFEST.MF
bundles/org.simantics.selectionview/src/org/simantics/selectionview/StandardSelectionProcessor.java
bundles/org.simantics.structural2/META-INF/MANIFEST.MF
bundles/org.simantics.structural2/src/org/simantics/structural2/queries/ConnectionPointMapOfResource.java
bundles/org.simantics.ui/META-INF/MANIFEST.MF
bundles/org.simantics.ui/src/org/simantics/ui/workbench/editor/GraphEditorAdapterDescriptor.java
bundles/org.simantics/src/org/simantics/Logger.java [deleted file]
bundles/org.simantics/src/org/simantics/Simantics.java
bundles/org.simantics/src/org/simantics/SimanticsPlatform.java

index e962c736ea08904de07945143c380f7564e1db58..9435da36da8ce4afdc554bd0a7c3257460f13aa5 100644 (file)
@@ -16,7 +16,8 @@ Require-Bundle: org.eclipse.ui,
  org.simantics.browsing.ui.model;bundle-version="1.0.0",
  org.simantics.modeling.ui;bundle-version="1.1.1",
  org.simantics.graph.db;bundle-version="1.1.9",
- org.simantics.views.swt.client;bundle-version="1.0.0"
+ org.simantics.views.swt.client;bundle-version="1.0.0",
+ org.slf4j.api;bundle-version="1.7.20"
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Bundle-Vendor: VTT Technical Research Centre of Finland
index 7a7977f33fe65807d1ebefd260404af0a449d647..f4f99997c5b0e1cd0191be2d4584e065576113a6 100644 (file)
@@ -34,7 +34,6 @@ import org.simantics.db.VirtualGraph;
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.UnaryRead;\r
 import org.simantics.db.common.request.WriteRequest;\r
-import org.simantics.db.common.utils.Logger;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.layer0.util.RemoverUtil;\r
@@ -60,6 +59,8 @@ import org.simantics.utils.strings.AlphanumComparator;
 import org.simantics.utils.ui.ISelectionUtils;\r
 import org.simantics.views.swt.client.base.ISWTViewNode;\r
 import org.simantics.views.swt.client.impl.SWTExplorer;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
 \r
 import gnu.trove.map.hash.THashMap;\r
 import gnu.trove.set.hash.THashSet;\r
@@ -69,6 +70,8 @@ import gnu.trove.set.hash.THashSet;
  * @author Tuukka Lehtonen\r
  */\r
 public class SCL {\r
+    \r
+    private static final Logger LOGGER = LoggerFactory.getLogger(SCL.class);\r
 \r
     final public static String EMPTY = "";\r
     final public static String MAPPED = "Mapped";\r
@@ -493,7 +496,7 @@ public class SCL {
                        try {\r
                                doAdd((Variable)properties.input);\r
                        } catch (DatabaseException e) {\r
-                               Logger.defaultLogError(e);\r
+                           LOGGER.error("newAnnotationModifier failed", e);\r
                        }\r
                        return null;\r
                        \r
@@ -670,7 +673,7 @@ public class SCL {
                        String name = graph.getPossibleRelatedValue(r, L0.HasName, Bindings.STRING);\r
                        if(name != null) {\r
                                if (result.put(name, r) != null)\r
-                                       System.err.println(this + ": The database contains siblings with the same name " + name + " (resource=$" + resource.getResourceId() +").");\r
+                                   LOGGER.error("The database contains siblings with the same name " + name + " (resource=$" + resource.getResourceId() +").");\r
                        }\r
                }\r
                return result;\r
index 89395e6ea39ae01daee675327a9b772f98317302..5ba6379d6a15a07f93d9f313320178e73acb6c8f 100644 (file)
@@ -14,7 +14,8 @@ Require-Bundle: org.simantics.db;bundle-version="1.1.0";visibility:=reexport,
  org.simantics.scl.runtime;bundle-version="0.1.4",
  org.simantics.user.ontology;bundle-version="1.0.0",
  org.simantics.layer0x.ontology;bundle-version="1.0.0",
- org.simantics.issues.ontology;bundle-version="1.2.0"
+ org.simantics.issues.ontology;bundle-version="1.2.0",
+ org.slf4j.api
 Export-Package: org.simantics.db.common,
  org.simantics.db.common.adaption,
  org.simantics.db.common.auth,
index 5a92ef62c894717a878058bcdfe9d1eb8757f318..1d06cc33d4c38ea4980b0089bdee0982c62cc0f4 100644 (file)
@@ -22,9 +22,13 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.layer0.Layer0;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
 \r
 public class PropertyMapOfResource extends ResourceRead<Map<String, Resource>> {\r
 \r
+    private static final Logger LOGGER = LoggerFactory.getLogger(PropertyMapOfResource.class);\r
+\r
        public PropertyMapOfResource(Resource resource) {\r
            super(resource);\r
        }\r
@@ -41,7 +45,7 @@ public class PropertyMapOfResource extends ResourceRead<Map<String, Resource>> {
                        if(name != null) {\r
                                        String escapedName = URIStringUtils.escape(name); \r
                            if (result.put(escapedName, predicate) != null)\r
-                               System.err.println(this + ": The database contains siblings with the same name " + name + " (resource=$" + resource.getResourceId() +").");\r
+                               LOGGER.error("The database contains siblings with the same name " + name + " (resource=$" + resource.getResourceId() +").");\r
                        }\r
                        }                               \r
                }\r
index 99b20ff73e6c4c055043485e97c8907b253a3aa2..1d92da9c839a1e86f2d80e12100a08555f0d2d15 100644 (file)
@@ -20,12 +20,17 @@ import org.simantics.db.Resource;
 import org.simantics.db.common.ProcedureBarrier;\r
 import org.simantics.db.common.WriteBindings;\r
 import org.simantics.db.common.procedure.adapter.AsyncMultiProcedureAdapter;\r
+import org.simantics.db.common.request.PropertyMapOfResource;\r
 import org.simantics.db.common.request.ResourceAsyncRead;\r
 import org.simantics.db.procedure.AsyncProcedure;\r
 import org.simantics.layer0.Layer0;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
 \r
 public class EscapedChildMapOfResource extends ResourceAsyncRead<Map<String, Resource>> {\r
 \r
+    private static final Logger LOGGER = LoggerFactory.getLogger(EscapedChildMapOfResource.class);\r
+\r
        public EscapedChildMapOfResource(Resource resource) {\r
            super(resource);\r
        }\r
@@ -50,7 +55,7 @@ public class EscapedChildMapOfResource extends ResourceAsyncRead<Map<String, Res
                                                if (name != null) {\r
                                                        String escapedName = URIStringUtils.escape((String)name); \r
                                                        if (map.put(escapedName, child) != null)\r
-                                                               System.err.println(this + ": The database contains siblings with the same name " + escapedName + " (resource=" + resource.getResourceId() +").");\r
+                                                           LOGGER.error("The database contains siblings with the same name " + escapedName + " (resource=" + resource.getResourceId() +").");\r
                                                }\r
                                                barrier.dec(g, procedure, map);\r
                                        }\r
index 303afddd00da0dbdc657891f45282c2eb09b0665..a3743f6377a46274d170cc473f28a2c50c943468 100644 (file)
@@ -22,9 +22,13 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.service.CollectionSupport;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.utils.Development;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
 \r
 public class UnescapedChildMapOfResource extends ResourceRead<Map<String, Resource>> {\r
 \r
+    private static final Logger LOGGER = LoggerFactory.getLogger(UnescapedChildMapOfResource.class);\r
+\r
        public UnescapedChildMapOfResource(Resource resource) {\r
            super(resource);\r
        }\r
@@ -40,10 +44,10 @@ public class UnescapedChildMapOfResource extends ResourceRead<Map<String, Resour
                if(name != null) {\r
                    Resource old = result.put(name, r);\r
                    if (old != null)\r
-                       System.err.println(this + ": The database contains siblings with the same name " + name + " (resource=$" + resource.getResourceId() + ", child=$" + r.getResourceId() + ", previous child=$" + old.getResourceId() + ").");\r
+                       LOGGER.error("The database contains siblings with the same name " + name + " (resource=$" + resource.getResourceId() + ", child=$" + r.getResourceId() + ", previous child=$" + old.getResourceId() + ").");\r
                } else {\r
                        if(Development.DEVELOPMENT)\r
-                           System.err.println(this + ": The database contains a child with no unique name (resource=$" + resource.getResourceId() + ", child=$" + r.getResourceId() + ").");\r
+                           LOGGER.error("The database contains a child with no unique name (resource=$" + resource.getResourceId() + ", child=$" + r.getResourceId() + ").");\r
                }\r
            }\r
            return result;\r
index a345498bee55b6124d612ca0d35ed82153496806..184361779afe2cee78c99351fab38ebdf212a8ce 100644 (file)
@@ -22,7 +22,8 @@ Require-Bundle:
  org.simantics.document.base.ontology;bundle-version="1.1.0",
  org.simantics.modeling;bundle-version="1.1.1",
  org.simantics.document.server.io;visibility:=reexport,
- org.simantics.scl.db;bundle-version="0.1.3"
+ org.simantics.scl.db;bundle-version="0.1.3",
+ org.slf4j.api
 Bundle-ActivationPolicy: lazy
 Bundle-Activator: org.simantics.document.server.Activator
 Export-Package: org.simantics.document.server,
index ca4adef25a280ff77bfcbbd4d1ff92184151d194..ef764bddc48870346b96b007c07e45acf40dedc0 100644 (file)
@@ -2,10 +2,12 @@ package org.simantics.document.server;
 \r
 import java.util.List;\r
 \r
-import org.simantics.Logger;\r
 import org.simantics.db.procedure.Listener;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
 \r
 public class DocumentHistoryListener implements Listener<List<JSONObject>> {\r
+    private static final Logger LOGGER = LoggerFactory.getLogger(DocumentHistoryListener.class);\r
 \r
        final private DocumentHistory history;\r
     \r
@@ -32,7 +34,7 @@ public class DocumentHistoryListener implements Listener<List<JSONObject>> {
 \r
     @Override\r
     public void exception(Throwable t) {\r
-       Logger.defaultLogError(t);\r
+        LOGGER.warn("DocumentHistoryListener received an exception.", t);\r
     }\r
     \r
     @Override\r
index 26f88608fb2e400fb34c46aad42002f03f4d8723..2e67010eba24bf013d9da01c884b3f7d174409b3 100644 (file)
@@ -4,15 +4,17 @@ import java.io.ByteArrayOutputStream;
 import java.io.PrintStream;\r
 import java.io.UnsupportedEncodingException;\r
 \r
-import org.simantics.Logger;\r
 import org.simantics.db.layer0.exception.MissingVariableException;\r
 import org.simantics.db.layer0.scl.SCLDatabaseException;\r
 import org.simantics.document.server.DocumentException;\r
 import org.simantics.scl.compiler.module.repository.ImportFailure;\r
 import org.simantics.scl.compiler.module.repository.ImportFailureException;\r
 import org.simantics.scl.compiler.top.NotFoundException;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
 \r
 public class NodeRequestUtils {\r
+    private static final Logger LOGGER = LoggerFactory.getLogger(NodeRequestUtils.class);\r
 \r
        public static String formatErrorMessage(String name, Throwable t) {\r
                \r
@@ -36,8 +38,8 @@ public class NodeRequestUtils {
                                sb.append(" " + f.moduleName + "\n");\r
                        return sb.toString();\r
                } else {\r
-                       Logger.defaultLogError(t);\r
-                       \r
+                   LOGGER.error("Node request error:", t);\r
+                   \r
                        ByteArrayOutputStream baos = new ByteArrayOutputStream();\r
                        PrintStream ps = new PrintStream(baos);\r
                        t.printStackTrace(ps);\r
index eadcf7e08be678758677bb3c7e08cac3d32ac497..88dfc79c7f1974a2b30c9c56eb21cb39904f07d5 100644 (file)
@@ -15,7 +15,8 @@ Require-Bundle: org.eclipse.core.runtime,
  org.simantics.utils.ui;bundle-version="1.1.0",
  org.simantics.graph.db;bundle-version="1.1.9",
  org.simantics;bundle-version="1.0.0",
- com.lowagie.text;bundle-version="2.1.7";resolution:=optional
+ com.lowagie.text;bundle-version="2.1.7";resolution:=optional,
+ org.slf4j.api
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Export-Package: org.simantics.export.core,
  org.simantics.export.core.error,
index c513654df6aae68705f78f3eeb3ca1d232d20e84..65cb53d13d4d5eb0fd734973398624f04d6368ee 100644 (file)
@@ -20,8 +20,9 @@ import java.util.function.Consumer;
 import org.osgi.framework.BundleContext;\r
 import org.osgi.framework.InvalidSyntaxException;\r
 import org.osgi.framework.ServiceReference;\r
-import org.simantics.Logger;\r
 import org.simantics.export.core.internal.Activator;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
 \r
 import com.lowagie.text.Document;\r
 import com.lowagie.text.Paragraph;\r
@@ -34,6 +35,7 @@ import com.lowagie.text.pdf.PdfWriter;
  * @since 1.22.2\r
  */\r
 public class ServiceBasedPdfExportPageEvent extends PdfPageEventHelper {\r
+    private static final Logger LOGGER = LoggerFactory.getLogger(ServiceBasedPdfExportPageEvent.class);\r
 \r
        Map<String, PdfExportPageEvent> events;\r
        \r
@@ -64,7 +66,7 @@ public class ServiceBasedPdfExportPageEvent extends PdfPageEventHelper {
                try {\r
                        r.accept(event);\r
                } catch (Exception e) {\r
-                       Logger.defaultLogError("Failed to invoke PdfExportPageEvent::" + eventName + " for " + event.toString(), e);\r
+                       LOGGER.error("Failed to invoke PdfExportPageEvent::" + eventName + " for " + event.toString(), e);\r
                }\r
        }\r
 \r
index e9f8ba1b9f587489a1d8b078d2deb75d13a4f883..0bc7d909d0794da47c7240ec71c5740b99f66c50 100644 (file)
@@ -12,7 +12,8 @@ Require-Bundle: org.eclipse.ui,
  org.eclipse.ui.editors;bundle-version="3.9.0",
  org.eclipse.jface.text;bundle-version="3.10.0",
  org.eclipse.core.resources;bundle-version="3.10.1",
- org.simantics.help.core
+ org.simantics.help.core,
+ org.slf4j.api
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Bundle-ActivationPolicy: lazy
 Bundle-ClassPath: .
index c5847ce0d0de332105d1f3a600556bd6aae8f849..6a5e2d9680930903385fba8309aad81850eef1b9 100644 (file)
@@ -2,7 +2,6 @@ package org.simantics.help.ui;
 \r
 import org.eclipse.ui.PartInitException;\r
 import org.eclipse.ui.PlatformUI;\r
-import org.simantics.Logger;\r
 import org.simantics.Simantics;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
@@ -16,8 +15,11 @@ import org.simantics.help.HelpResources;
 import org.simantics.ui.workbench.ResourceEditorInput2;\r
 import org.simantics.ui.workbench.editor.AbstractResourceEditorAdapter;\r
 import org.simantics.utils.ui.workbench.WorkbenchUtils;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
 \r
 public class OpenHelpFileAdapter extends AbstractResourceEditorAdapter {\r
+    private static final Logger LOGGER = LoggerFactory.getLogger(OpenHelpFileAdapter.class);\r
 \r
     public OpenHelpFileAdapter() {\r
         super("Help File Editor");\r
@@ -49,7 +51,7 @@ public class OpenHelpFileAdapter extends AbstractResourceEditorAdapter {
                             String editorId = getEditorId();\r
                             WorkbenchUtils.openEditor(editorId, new ResourceEditorInput2(editorId, input, model, rvi));\r
                         } catch (PartInitException e) {\r
-                            Logger.defaultLogError(e);\r
+                            LOGGER.error("Failed to open an editor for help file.", e);\r
                         }\r
                     }\r
                 });\r
index 4216065175ad0eb2acb1a84f5ea29b95fa11e052..23b688bcda5d0561a6bf8a66b75b8d0b16463289 100644 (file)
@@ -11,7 +11,8 @@ Require-Bundle: org.simantics.issues;bundle-version="1.1.0",
  org.simantics.layer0.utils;bundle-version="0.6.2",
  org.simantics.db.services;bundle-version="0.6.2",
  org.simantics;bundle-version="1.0.0",
- org.simantics.issues.ui.ontology;bundle-version="1.0.0"
+ org.simantics.issues.ui.ontology;bundle-version="1.0.0",
+ org.slf4j.api
 Export-Package: org.simantics.issues.common,
  org.simantics.issues.common.preferences
 Bundle-Vendor: VTT Technical Research Centre of Finland
index 7c6cdeccf792d00f214cccd45ff6d18703af8a03..2f8c42b902e56960908d796697de0961bef0d90a 100644 (file)
@@ -5,7 +5,6 @@ import java.util.HashSet;
 import java.util.List;\r
 import java.util.Set;\r
 \r
-import org.simantics.Logger;\r
 import org.simantics.db.Issue;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
@@ -17,8 +16,11 @@ import org.simantics.db.common.utils.NameUtils;
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.issues.ontology.IssueResource;\r
 import org.simantics.layer0.Layer0;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
 \r
 public class DependencyIssueValidator2 extends ResourceRead3<Boolean> {\r
+    private static final Logger LOGGER = LoggerFactory.getLogger(DependencyIssueValidator2.class);\r
 \r
        public static final boolean DEBUG = false;\r
 \r
@@ -65,7 +67,7 @@ public class DependencyIssueValidator2 extends ResourceRead3<Boolean> {
                        if(DEBUG) System.err.println("Validator found: " + contexts.size() + " issues (" + contexts + ")");\r
                        return contexts;\r
                        } catch (DatabaseException e) {\r
-                               Logger.defaultLogError(e);\r
+                               LOGGER.error("Reading a constraint validator failed", e);\r
                                return Collections.emptySet();\r
                        }\r
                \r
index 26f0167ad6a2098a965ee61b1038230e1e939a4a..f1dcadc892b95cab535904f865a5c117f2e8cfdc 100644 (file)
@@ -25,7 +25,6 @@ import java.util.Set;
 import java.util.UUID;\r
 import java.util.concurrent.atomic.AtomicBoolean;\r
 \r
-import org.simantics.Logger;\r
 import org.simantics.Simantics;\r
 import org.simantics.databoard.Bindings;\r
 import org.simantics.databoard.util.URIStringUtils;\r
@@ -57,11 +56,14 @@ import org.simantics.layer0.Layer0;
 import org.simantics.operation.Layer0X;\r
 import org.simantics.scl.runtime.function.FunctionImpl2;\r
 import org.simantics.utils.datastructures.Pair;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
 \r
 /**\r
  * @author Tuukka Lehtonen\r
  */\r
 public class IssueUtils {\r
+    private static final Logger LOGGER = LoggerFactory.getLogger(IssueUtils.class);\r
 \r
     public static Resource toSeverityResource(IssueResource ISSUE, Severity severity) {\r
         switch (severity) {\r
@@ -113,7 +115,7 @@ public class IssueUtils {
                         });\r
                     }\r
                 } catch (DatabaseException e) {\r
-                    Logger.defaultLogError(e);\r
+                    LOGGER.error("Updating issue source failed.", e);\r
                 }\r
             } else {\r
                 Session session = Simantics.getSession();\r
@@ -173,7 +175,7 @@ public class IssueUtils {
 \r
             @Override\r
             public void exception(ReadGraph graph, Throwable throwable) throws DatabaseException {\r
-                Logger.defaultLogError(throwable);\r
+                LOGGER.error("IssueValidityListener received an exception.", throwable);\r
             }\r
 \r
         }\r
@@ -207,7 +209,7 @@ public class IssueUtils {
 \r
         @Override\r
         public void exception(ReadGraph graph, Throwable t) {\r
-            Logger.defaultLogError(t);\r
+            LOGGER.error("IssueSourceManagedIssuesListener received an exception.", t);\r
         }\r
 \r
         @Override\r
@@ -263,7 +265,7 @@ public class IssueUtils {
 \r
         @Override\r
         public void exception(ReadGraph graph, Throwable t) {\r
-            Logger.defaultLogError(t);\r
+            LOGGER.error("ActiveIssueSourceListener received an exception.", t);\r
         }\r
 \r
         @Override\r
index 76aec39f30184755d4f1f67103611eabc95c21f4..f396a58152a00e9d00747388ce43d407398832ed 100644 (file)
@@ -61,7 +61,8 @@ Require-Bundle: org.simantics.project;bundle-version="1.0.0",
  org.simantics.db.layer0,
  org.simantics.silk.ontology;bundle-version="1.1.0",
  org.simantics.image.ui;bundle-version="1.0.0",
- org.simantics.export.core;bundle-version="1.0.0"
+ org.simantics.export.core;bundle-version="1.0.0",
+ org.slf4j.api
 Export-Package: org.simantics.modeling.ui,
  org.simantics.modeling.ui.actions,
  org.simantics.modeling.ui.chart.property,
index 47d5643a17557b4a1208917bb2707323c98cab8e..ea50134d75ed0d728d6706175066299b8186cb0d 100644 (file)
@@ -33,7 +33,6 @@ import org.eclipse.jface.action.ActionContributionItem;
 import org.eclipse.jface.action.IContributionItem;\r
 import org.eclipse.jface.action.MenuManager;\r
 import org.eclipse.jface.action.Separator;\r
-import org.simantics.Logger;\r
 import org.simantics.browsing.ui.NodeContext;\r
 import org.simantics.browsing.ui.common.NodeContextBuilder;\r
 import org.simantics.browsing.ui.model.InvalidContribution;\r
@@ -42,13 +41,17 @@ import org.simantics.browsing.ui.model.actions.IActionCategory;
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.issues.common.IssueUtils;\r
 import org.simantics.modeling.ui.Activator;\r
 import org.simantics.project.ontology.ProjectResource;\r
 import org.simantics.ui.contribution.DynamicMenuContribution;\r
 import org.simantics.ui.selection.WorkbenchSelectionElement;\r
 import org.simantics.ui.selection.WorkbenchSelectionUtils;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
 \r
 public class ModeledActions extends DynamicMenuContribution implements IExecutableExtension {\r
+    private static final Logger LOGGER = LoggerFactory.getLogger(IssueUtils.class);\r
 \r
     public static final Set<String> defaultBrowseContexts = Collections.singleton(ProjectResource.URIs.ProjectActionContext);\r
 \r
@@ -121,7 +124,7 @@ public class ModeledActions extends DynamicMenuContribution implements IExecutab
                                                result.add(NodeContextBuilder.buildWithInput(res));\r
                                        }\r
                                } catch (DatabaseException e) {\r
-                                       Logger.defaultLogError(e);\r
+                                   LOGGER.error("Failed to get node contexts for selection.", e);\r
                                }\r
             }\r
         }\r
index 1ad4cd5394c8b95146577bd6690c13402e5ea38c..477a5543b9ecfcb79b8664d240731121ffad4bcf 100644 (file)
@@ -38,7 +38,6 @@ import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.forms.widgets.Form;\r
 import org.eclipse.ui.forms.widgets.FormToolkit;\r
 import org.eclipse.ui.forms.widgets.Section;\r
-import org.simantics.Logger;\r
 import org.simantics.Simantics;\r
 import org.simantics.databoard.Bindings;\r
 import org.simantics.db.ReadGraph;\r
@@ -63,9 +62,13 @@ import org.simantics.modeling.userComponent.ComponentTypeCommands;
 import org.simantics.selectionview.SelectionViewResources;\r
 import org.simantics.structural.stubs.StructuralResource2;\r
 import org.simantics.utils.datastructures.Pair;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
 \r
 public class ConfigurationPropertiesSection implements ComponentTypeViewerSection {\r
 \r
+    private static final Logger LOGGER = LoggerFactory.getLogger(ConfigurationPropertiesSection.class);\r
+    \r
     private static final String[] COLUMN_NAMES = \r
             new String[] {"Name", "Type", "Default Value", "Unit", "Range", "Label", "Description"};\r
     private static final int[] COLUMN_LENGTHS =\r
@@ -443,7 +446,7 @@ public class ConfigurationPropertiesSection implements ComponentTypeViewerSectio
 \r
                 } catch (DatabaseException e1) {\r
                     \r
-                    Logger.defaultLogError(e1);\r
+                    LOGGER.error("Lifting properties failed", e1);\r
                     return;\r
                     \r
                 }\r
@@ -565,7 +568,7 @@ public class ConfigurationPropertiesSection implements ComponentTypeViewerSectio
                 }\r
             });\r
         } catch (DatabaseException e) {\r
-            Logger.defaultLogError(e);\r
+            LOGGER.error("Finding UserDefinedProperties failed.", e);\r
             return Collections.emptyMap();\r
         }\r
     }\r
index 207257baa260cacac6dafcdafcebcdff69179ef3..0a4ca49b4f689aebb77a2b919382541a4ffc9588 100644 (file)
@@ -13,7 +13,6 @@ package org.simantics.modeling.ui.diagramEditor;
 \r
 import org.eclipse.ui.PartInitException;\r
 import org.eclipse.ui.PlatformUI;\r
-import org.simantics.Logger;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.common.request.PossibleIndexRoot;\r
@@ -28,8 +27,11 @@ import org.simantics.ui.SimanticsUI;
 import org.simantics.ui.workbench.ResourceEditorInput2;\r
 import org.simantics.ui.workbench.editor.AbstractResourceEditorAdapter;\r
 import org.simantics.utils.ui.workbench.WorkbenchUtils;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
 \r
 public class OpenSheetAdapter extends AbstractResourceEditorAdapter {\r
+    private static final Logger LOGGER = LoggerFactory.getLogger(OpenSheetAdapter.class);\r
 \r
     private static final String EDITOR_ID = "org.simantics.spreadsheet.ui.editor2";\r
 \r
@@ -63,7 +65,7 @@ public class OpenSheetAdapter extends AbstractResourceEditorAdapter {
                             String editorId = getEditorId();\r
                             WorkbenchUtils.openEditor(editorId, new ResourceEditorInput2(editorId, r, model, rvi));\r
                         } catch (PartInitException e) {\r
-                               Logger.defaultLogError(e);\r
+                               LOGGER.error("Failed to open the spreadsheet editor.", e);\r
                         }\r
                     }\r
                 });\r
index 0deeb1be1a7f02c49fa2e82084320c83e749832e..959bbbe6f4bc94fcc6cb2bab3fad85112f5a0f19 100644 (file)
@@ -11,8 +11,6 @@
  *******************************************************************************/\r
 package org.simantics.modeling.ui.diagramEditor;\r
 \r
-import gnu.trove.set.hash.THashSet;\r
-\r
 import java.awt.datatransfer.Transferable;\r
 import java.awt.datatransfer.UnsupportedFlavorException;\r
 import java.awt.dnd.DnDConstants;\r
@@ -25,7 +23,6 @@ import java.util.HashMap;
 import java.util.List;\r
 \r
 import org.eclipse.jface.viewers.IStructuredSelection;\r
-import org.simantics.Logger;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.RequestProcessor;\r
 import org.simantics.db.Resource;\r
@@ -64,8 +61,13 @@ import org.simantics.ui.selection.WorkbenchSelectionUtils;
 import org.simantics.utils.datastructures.Triple;\r
 import org.simantics.utils.datastructures.hints.IHintContext;\r
 import org.simantics.utils.ui.ISelectionUtils;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+import gnu.trove.set.hash.THashSet;\r
 \r
 public class PopulateElementMonitorDropParticipant extends PopulateElementDropParticipant implements IDropTargetParticipant {\r
+    private static final Logger LOGGER = LoggerFactory.getLogger(PopulateElementMonitorDropParticipant.class);\r
 \r
     private static final boolean DEBUG = false;\r
 \r
@@ -129,14 +131,9 @@ public class PopulateElementMonitorDropParticipant extends PopulateElementDropPa
                     dp.getHints().setHint(DnDHints.KEY_DND_GRID_COLUMNS, Integer.valueOf(1));\r
                 }\r
 \r
-            } catch (UnsupportedFlavorException e) {\r
-                Logger.defaultLogError(e);\r
-            } catch (IOException e) {\r
-                Logger.defaultLogError(e);\r
-            } catch (DatabaseException e) {\r
-                Logger.defaultLogError(e);\r
+            } catch (UnsupportedFlavorException|IOException|DatabaseException e) {\r
+                LOGGER.error("dragEnter failed", e);\r
             }\r
-\r
         }\r
 \r
         dtde.acceptDrag(DnDConstants.ACTION_COPY);\r
index 249d9ec7c22cba7b55a726726ac1422e49987ff5..5245ed47e7665fb1abe384033ad087367844f446 100644 (file)
@@ -36,7 +36,8 @@ Require-Bundle: org.simantics.simulation;bundle-version="1.0.0",
  org.simantics.scenegraph.profile;bundle-version="1.0.0",
  org.simantics.scl.db;bundle-version="0.1.3",
  org.simantics.selectionview.ontology;bundle-version="1.2.0",
- org.simantics.scl.ui;bundle-version="0.5.0"
+ org.simantics.scl.ui;bundle-version="0.5.0",
+ org.slf4j.api
 Export-Package: org.simantics.modeling,
  org.simantics.modeling.actions,
  org.simantics.modeling.adapters,
index 555401327c89b48c4bd7cb73355f35a611710796..bfa42b40e18707e020bd27b0d0a9fb9de3654a8f 100644 (file)
@@ -10,7 +10,6 @@ import org.eclipse.core.runtime.Platform;
 import org.eclipse.core.runtime.jobs.IJobManager;\r
 import org.eclipse.core.runtime.jobs.Job;\r
 import org.simantics.DatabaseJob;\r
-import org.simantics.Logger;\r
 import org.simantics.Simantics;\r
 import org.simantics.SimanticsPlatform;\r
 import org.simantics.SimanticsPlatform.OntologyRecoveryPolicy;\r
@@ -24,8 +23,12 @@ import org.simantics.db.layer0.request.external.EclipsePreferencePrimitiveRead;
 import org.simantics.db.layer0.util.RemoverUtil;\r
 import org.simantics.db.layer0.util.SimanticsClipboard;\r
 import org.simantics.db.service.DebugSupport;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
 \r
 public class SCL {\r
+    private static final Logger LOGGER = LoggerFactory.getLogger(SCL.class);\r
+\r
     public static void killPlatformWrite(WriteGraph graph) throws DatabaseException {\r
         // Currently not supported.\r
         // Would be relatively easy to support the desired functionality.\r
@@ -109,7 +112,7 @@ public class SCL {
        try {\r
                        Thread.sleep(ms);\r
                } catch (InterruptedException e) {\r
-                       Logger.defaultLogError(e);\r
+            LOGGER.warn("Sleep was interrupted.", e);\r
                }\r
     }\r
 \r
index 99ac161a5baf9c0af866da158c9fe88ad735616f..8ed8c3e0e199c282aeacdd0aadf1f0a7d9735521 100644 (file)
@@ -1,7 +1,5 @@
 package org.simantics.modeling.scl;\r
 \r
-import gnu.trove.map.hash.THashMap;\r
-\r
 import java.io.IOException;\r
 import java.util.Map;\r
 import java.util.concurrent.ExecutorService;\r
@@ -11,7 +9,6 @@ import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.ThreadPoolExecutor;\r
 import java.util.concurrent.TimeUnit;\r
 \r
-import org.simantics.Logger;\r
 import org.simantics.databoard.Bindings;\r
 import org.simantics.databoard.binding.Binding;\r
 import org.simantics.databoard.binding.mutable.Variant;\r
@@ -24,8 +21,14 @@ import org.simantics.scl.runtime.function.Function;
 import org.simantics.scl.runtime.tuple.Tuple0;\r
 import org.simantics.simulator.variable.NodeManager;\r
 import org.simantics.simulator.variable.Realm;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+import gnu.trove.map.hash.THashMap;\r
 \r
 public class SCLRealm implements Realm {\r
+    private static final Logger LOGGER = LoggerFactory.getLogger(SCLRealm.class);\r
+\r
     public static final String SCL = "scl";\r
     \r
     THashMap<String,Type> contextTypes = new THashMap<String,Type>();\r
@@ -118,7 +121,7 @@ public class SCLRealm implements Realm {
             try {\r
                 runnable.run();\r
             } catch (Throwable t) {\r
-               Logger.defaultLogError(t);\r
+                LOGGER.error("Runnable failed in syncExec.", t);\r
             } finally {\r
             }\r
             return;\r
@@ -132,7 +135,7 @@ public class SCLRealm implements Realm {
         try {\r
             runnable.run();\r
         } catch (Throwable t) {\r
-               Logger.defaultLogError(t);\r
+            LOGGER.error("Runnable failed in syncExec.", t);\r
         } finally {\r
             executorThread = oldThread;\r
             endSyncExec.release();\r
@@ -146,7 +149,7 @@ public class SCLRealm implements Realm {
             try {\r
                 runnable.run();\r
             } catch (Throwable t) {\r
-               Logger.defaultLogError(t);\r
+                LOGGER.error("Runnable failed in asyncExec.", t);\r
             } finally {\r
             }\r
             return;\r
index cd326051371169ad70b442b8b986300c336cbce2..96a33393aeac5bab1c972d995cd1e0754a33ae71 100644 (file)
@@ -24,7 +24,6 @@ import java.util.Map;
 import java.util.Set;\r
 \r
 import org.eclipse.core.runtime.IProgressMonitor;\r
-import org.simantics.Logger;\r
 import org.simantics.Simantics;\r
 import org.simantics.databoard.Bindings;\r
 import org.simantics.db.ReadGraph;\r
@@ -81,6 +80,8 @@ import org.simantics.utils.datastructures.MapSet;
 import org.simantics.utils.strings.AlphanumComparator;\r
 import org.simantics.utils.strings.EString;\r
 import org.simantics.utils.ui.ErrorLogger;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
 \r
 import gnu.trove.map.hash.THashMap;\r
 import gnu.trove.set.hash.THashSet;\r
@@ -102,6 +103,7 @@ import gnu.trove.set.hash.THashSet;
  * @see TypicalSynchronizationMetadata\r
  */\r
 public class SyncTypicalTemplatesToInstances extends WriteRequest {\r
+    private static final Logger LOGGER = LoggerFactory.getLogger(SyncTypicalTemplatesToInstances.class);\r
 \r
     /**\r
      * A constant used as the second argument to\r
@@ -423,8 +425,7 @@ public class SyncTypicalTemplatesToInstances extends WriteRequest {
                 syncInstance(graph, template, instance, templateElements);\r
             }\r
         } catch (Exception e) {\r
-               Logger.defaultLogError(e);\r
-               e.printStackTrace();\r
+            LOGGER.error("Template synchronization failed.", e);\r
         } finally {\r
             this.temporaryDiagram.removeHint(DiagramModelHints.KEY_DIAGRAM_RESOURCE);\r
         }\r
index ec287cffc3612ebe3e11035fceeb2fb5ca4621d6..42e503aab6b432ee9bb7f18536484aea7dfb3b11 100644 (file)
@@ -33,12 +33,12 @@ Require-Bundle: org.simantics.db.layer0;bundle-version="[0.8.0,2.0.0)",
  org.eclipse.equinox.p2.touchpoint.natives;bundle-version="1.0.200",
  org.eclipse.equinox.p2.transport.ecf;bundle-version="1.0.0",
  org.simantics.graph.db;bundle-version="1.0.0",
- org.apache.log4j;bundle-version="1.2.15",
  org.simantics.db.procore;bundle-version="1.1.0",
  org.eclipse.swt;bundle-version="3.6.0";resolution:=optional,
  org.eclipse.core.resources;bundle-version="3.6.0";resolution:=optional,
  org.simantics.graph.compiler;bundle-version="1.1.10",
- org.simantics.ltk;bundle-version="1.1.10"
+ org.simantics.ltk;bundle-version="1.1.10",
+ org.slf4j.api
 Export-Package: org.eclipse.equinox.internal.p2.ui.query,
  org.eclipse.equinox.internal.provisional.p2.installer,
  org.simantics.project,
index 56cf3254c465300a5a8e1188d2015e9b58a37bca..205706c48c0bab2e7b63d864540f0f70a37f4572 100644 (file)
@@ -22,7 +22,6 @@ import java.util.HashMap;
 import java.util.Map;\r
 import java.util.Properties;\r
 \r
-import org.apache.log4j.Logger;\r
 import org.simantics.databoard.util.StreamUtil;\r
 import org.simantics.db.Driver;\r
 import org.simantics.db.Driver.Management;\r
@@ -40,6 +39,8 @@ import org.simantics.db.service.XSupport;
 import org.simantics.graph.db.CoreInitialization;\r
 import org.simantics.layer0.DatabaseManagementResource;\r
 import org.simantics.layer0.Layer0;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
 \r
 /**\r
  * Server Manager handles starting and pooling of ProCore server instances.\r
@@ -47,7 +48,8 @@ import org.simantics.layer0.Layer0;
  * @author Toni Kalajainen <toni.kalajainen@vtt.fi>\r
  */\r
 public class ServerManager {\r
-\r
+    private static final Logger LOGGER = LoggerFactory.getLogger(ServerManager.class);\r
+    \r
        /** Default properties with default user and password */\r
        public static final Properties DEFAULT;\r
 \r
@@ -81,8 +83,7 @@ public class ServerManager {
         */\r
        public Session createDatabase(File databaseDirectory) throws DatabaseException {\r
                try {\r
-                       Logger myLogger = Logger.getLogger(ServerManager.class);\r
-                       myLogger.debug("Creating database to "+ databaseDirectory);\r
+                   LOGGER.debug("Creating database to "+ databaseDirectory);\r
 \r
             Session session = null;\r
             ServerEx server1 = getServer(databaseDirectory);\r
@@ -206,8 +207,7 @@ public class ServerManager {
                     if (server.isActive())\r
                         server.stop();\r
                 } catch (DatabaseException e) {\r
-                    Logger myLogger = Logger.getLogger(ServerManager.class);\r
-                    myLogger.error(e);\r
+                    LOGGER.error("Failed to stop database server.", e);\r
                 }\r
                        }\r
                        servers.clear();\r
index 8957a21679b45607a2daab8d235b7e90545c93c6..65190614c4dc52612decf0fda5bdca32d9b0e8a4 100644 (file)
@@ -22,19 +22,21 @@ import java.net.URLDecoder;
 import java.util.zip.ZipEntry;\r
 import java.util.zip.ZipInputStream;\r
 \r
-import org.apache.log4j.Logger;\r
 import org.simantics.db.DatabaseUserAgent;\r
 import org.simantics.db.Driver;\r
 import org.simantics.db.Manager;\r
 import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.utils.FileUtils;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
 \r
 public class ServerManagerFactory {\r
+    private static final Logger LOGGER = LoggerFactory.getLogger(ServerManagerFactory.class);\r
+\r
     public static ServerManager create(String databaseDriverId, String address) throws IOException, DatabaseException {\r
         Driver driver = Manager.getDriver(databaseDriverId);\r
         if (driver == null)\r
             throw new IllegalArgumentException("Database driver with ID " + databaseDriverId + " could not be found!");\r
-        System.out.println("ServerManagerFactory.create called with id " + databaseDriverId + ", driver is " + driver.toString());\r
+        LOGGER.info("ServerManagerFactory.create called with id {}, driver is {}.", databaseDriverId, driver);\r
         DatabaseUserAgent agent = Manager.getUserAgent(databaseDriverId);\r
         if (agent != null)\r
             driver.setDatabaseUserAgent(address, agent);\r
@@ -166,7 +168,6 @@ public class ServerManagerFactory {
      * @throws IOException\r
      */\r
     private static void extractZip(InputStream zipInput, File dst) throws IOException {\r
-        Logger myLogger = Logger.getLogger(FileUtils.class);\r
         byte[] buf = new byte[8192];\r
         ZipInputStream zis = new ZipInputStream(zipInput);\r
         ZipEntry entry;\r
@@ -175,7 +176,7 @@ public class ServerManagerFactory {
         while (entry != null) {\r
             // for each entry to be extracted\r
             String name = entry.getName();\r
-            myLogger.debug("Extracting "+name);\r
+            LOGGER.debug("Extracting "+name);\r
             File file = new File(dst, name);\r
 \r
             if (entry.isDirectory())\r
index edf93841b5c9ba1adf7420238ee7c24451ed81c6..e01098c12df762eb3e32c43caaff6baaee3f36c6 100755 (executable)
@@ -207,8 +207,6 @@ public abstract class Expression extends Symbol implements Typed {
     public abstract void collectFreeVariables(THashSet<Variable> vars);\r
     \r
     public Expression simplify(SimplificationContext context) {\r
-        System.out.println("#############################");\r
-        System.out.println(this);\r
         throw new InternalCompilerError(location, getClass().getSimpleName() + " does not support simplify method.");\r
     }\r
 \r
index 26111e0b43bf781e3e922debfb61ca1eb61e09b8..c9fa469d28f748fbea80fdfbd623399118437466 100644 (file)
@@ -67,13 +67,9 @@ public class TransitiveClosureRelation extends AbstractRelation implements Compo
             type = type.replace(getTypeVariables(), typeParameters);
 
         Expression continuation = context.getContinuation();
-        System.out.println("continuation = " + continuation + " :: " + continuation.getType());
         Variable set = new Variable("set", Types.apply(Types.con("MSet", "T"), type));
         Variable f = new Variable("f", Types.functionE(type, Types.PROC, continuation.getType()));
         Variable innerSolved = new Variable("tcTemp", solved.getType());
-        System.out.println("set :: " + set.getType());
-        System.out.println("f :: " + f.getType());
-        System.out.println("tcTemp :: " + innerSolved.getType());
         
         QueryCompilationContext newContext = context.createSubcontext(new EApply(
                 new EVariable(f), new EVariable(innerSolved)
index 64d5ac63dbeccba336c6b73cc6fd463e016a9497..7274b0bf2dde4515d4667f6138a2a3f24be814fb 100755 (executable)
@@ -21,4 +21,5 @@ Export-Package: org.simantics.scl.runtime,
  org.simantics.scl.runtime.xml
 Require-Bundle: org.junit;bundle-version="4.12.0";resolution:=optional,
  gnu.trove3;bundle-version="3.0.0",
- org.simantics.databoard;bundle-version="0.6.5";visibility:=reexport
+ org.simantics.databoard;bundle-version="0.6.5";visibility:=reexport,
+ org.slf4j.api;bundle-version="1.7.20"
index a5359564632fe1b7edabc3d6f3055fde8fc8eb4a..91e71d6521836314fb2c05b6140f8419df597137 100755 (executable)
@@ -1,5 +1,8 @@
 package org.simantics.scl.runtime.reporting;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 /**
  * <p>An interface that is used to handle printing commands from SCL 
  * such as Prelude.print. This interface is typically stored to 
@@ -11,6 +14,7 @@ package org.simantics.scl.runtime.reporting;
  * @author Hannu Niemist&ouml;
  */
 public interface SCLReportingHandler {
+    public static final Logger LOGGER = LoggerFactory.getLogger(SCLReportingHandler.class);
     public static final String REPORTING_HANDLER = "reportingHandler";
     
     public void print(String text);
@@ -19,6 +23,34 @@ public interface SCLReportingHandler {
     public void didWork(double amount);
 
     public static final SCLReportingHandler DEFAULT = new AbstractSCLReportingHandler() {
+        @Override
+        public void print(String text) {
+            LOGGER.info(text);
+        }
+
+        @Override
+        public void printError(String error) {
+            LOGGER.error(error);
+        }
+    };
+    
+    public static final SCLReportingHandler DEFAULT_WITHOUT_ECHO = new AbstractSCLReportingHandler() {
+        @Override
+        public void print(String text) {
+            LOGGER.info(text);
+        }
+
+        @Override
+        public void printError(String error) {
+            LOGGER.error(error);
+        }
+
+        @Override
+        public void printCommand(String command) {
+        }
+    };
+    
+    public static final SCLReportingHandler SYSOUT = new AbstractSCLReportingHandler() {
         @Override
         public void print(String text) {
             System.out.println(text);
@@ -30,7 +62,7 @@ public interface SCLReportingHandler {
         }
     };
     
-    public static final SCLReportingHandler DEFAULT_WITHOUT_ECHO = new AbstractSCLReportingHandler() {
+    public static final SCLReportingHandler SYSOUT_WITHOUT_ECHO = new AbstractSCLReportingHandler() {
         @Override
         public void print(String text) {
             System.out.println(text);
index 606078e6c1b30ae44a67bddb848b5f5b067090a4..1652bea8f14e645998e6912a6fad5e45d52c4bb2 100644 (file)
@@ -21,7 +21,8 @@ Require-Bundle: org.eclipse.ui,
  org.simantics.views.ontology;bundle-version="1.0.0",
  org.simantics.browsing.ui.model;bundle-version="1.0.0",
  org.simantics.modeling;bundle-version="1.1.1",
- org.simantics.scenegraph.ontology;bundle-version="1.0.0"
+ org.simantics.scenegraph.ontology;bundle-version="1.0.0",
+ org.slf4j.api
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Bundle-ActivationPolicy: lazy
 Export-Package: org.simantics.selectionview
index 7b5cdf98c007972495c948de0a5fe46284ab72e2..ccf4eeb9ff79391a64f5e8be25f2fc24d9cbe85f 100644 (file)
@@ -6,7 +6,7 @@ import java.util.Collections;
 import java.util.HashSet;\r
 import java.util.Set;\r
 \r
-import org.simantics.Logger;\r
+import org.simantics.Simantics;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.common.request.PossibleIndexRoot;\r
@@ -21,8 +21,11 @@ import org.simantics.db.layer0.variable.Variables;
 import org.simantics.layer0.Layer0;\r
 import org.simantics.ui.selection.WorkbenchSelectionUtils;\r
 import org.simantics.utils.ui.ISelectionUtils;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
 \r
 public class StandardSelectionProcessor implements SelectionProcessor<Object, ReadGraph> {\r
+    private static final Logger LOGGER = LoggerFactory.getLogger(StandardSelectionProcessor.class);\r
 \r
        private static Resource getIndexRoot(ReadGraph graph, Object selection) throws DatabaseException {\r
                \r
@@ -113,10 +116,8 @@ public class StandardSelectionProcessor implements SelectionProcessor<Object, Re
                                                        }\r
                                                        if (c.accept(graph, input))\r
                                                                c.contribute(graph, input, result);\r
-                                               } catch (ClassCastException e) {\r
-                                                       Logger.defaultLogError(e);\r
                                                } catch (Exception e) {\r
-                                                       Logger.defaultLogError(e);\r
+                                                       LOGGER.error("Selection view tab contribution failed.", e);\r
                                                }\r
                                        }\r
                                }\r
index 94409e4d25d17202c517b9fe9c6026972f5e8918..ad3c50facba1a792dce116d2f575564a223e1b18 100644 (file)
@@ -23,3 +23,4 @@ Export-Package: org.simantics.structural2,
 Bundle-Vendor: VTT Technical Research Centre of Finland
 Bundle-ActivationPolicy: lazy
 Bundle-Activator: org.simantics.structural2.internal.Activator
+Import-Package: org.slf4j
index 2dff0a74006baa38fe9f1669ff5a037f60e2fde0..2924b3dac14dea30174526ab7d141c30fac457a6 100644 (file)
@@ -11,8 +11,6 @@
  *******************************************************************************/\r
 package org.simantics.structural2.queries;\r
 \r
-import gnu.trove.map.hash.THashMap;\r
-\r
 import java.util.Collection;\r
 import java.util.Collections;\r
 import java.util.Map;\r
@@ -25,9 +23,15 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.request.PropertyInfo;\r
 import org.simantics.db.request.RequestFlags;\r
 import org.simantics.db.service.QueryControl;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+import gnu.trove.map.hash.THashMap;\r
 \r
 public class ConnectionPointMapOfResource extends TransientResourceRead<Map<String, Resource>> {\r
 \r
+    private static final Logger LOGGER = LoggerFactory.getLogger(ConnectionPointMapOfResource.class);\r
+\r
        public ConnectionPointMapOfResource(ReadGraph graph, Resource resource) throws DatabaseException {\r
            super(graph, resource);\r
        }\r
@@ -49,7 +53,7 @@ public class ConnectionPointMapOfResource extends TransientResourceRead<Map<Stri
                        if(info != null) {\r
                                if (result == null) result = new THashMap<String,Resource>(predicates.size());\r
                                if (result.put(info.name, predicate) != null)\r
-                                       System.err.println(this + ": The database contains siblings with the same name " + info.name + " (resource=$" + resource.getResourceId() + ").");\r
+                                   LOGGER.error("The database contains siblings with the same name " + info.name + " (resource=$" + resource.getResourceId() + ").");\r
                        }                               \r
                        \r
                }\r
index 73c65c06ff844114f4cd04902688b0851603a3ef..4b043cee14f0b92c3bbd13690d3d3881191d8ffd 100644 (file)
@@ -29,7 +29,8 @@ Require-Bundle: org.eclipse.core.runtime,
  org.eclipse.e4.ui.workbench,\r
  org.eclipse.e4.ui.di,\r
  org.eclipse.e4.ui.bindings,\r
- org.simantics.modeling.ontology;bundle-version="1.2.0"\r
+ org.simantics.modeling.ontology;bundle-version="1.2.0",\r
+ org.slf4j.api\r
 Bundle-ActivationPolicy: lazy\r
 Export-Package: org.simantics.ui,\r
  org.simantics.ui.colors,\r
index 3ffa5b4570fb5758985bb5e81f63e4eeadc48c7d..b5bb6191c3b65501f1ea5ef13c3b12b8d246658d 100644 (file)
@@ -5,7 +5,6 @@ import java.util.Collection;
 import org.eclipse.jface.resource.ImageDescriptor;\r
 import org.eclipse.ui.PartInitException;\r
 import org.eclipse.ui.PlatformUI;\r
-import org.simantics.Logger;\r
 import org.simantics.Simantics;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
@@ -19,9 +18,12 @@ import org.simantics.modeling.ModelingResources;
 import org.simantics.ui.utils.ResourceAdaptionUtils;\r
 import org.simantics.ui.workbench.ResourceEditorInput2;\r
 import org.simantics.utils.ui.workbench.WorkbenchUtils;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
 \r
 public class GraphEditorAdapterDescriptor implements EditorAdapterDescriptor {\r
-       \r
+    private static final Logger LOGGER = LoggerFactory.getLogger(GraphEditorAdapterDescriptor.class);\r
+\r
        private final String editorId;\r
        private final String label;\r
        private final ImageDescriptor imageDescriptor;\r
@@ -95,7 +97,7 @@ public class GraphEditorAdapterDescriptor implements EditorAdapterDescriptor {
                                        try {\r
                                            WorkbenchUtils.openEditor(editorId, new ResourceEditorInput2(editorId, r, model, rvi));\r
                                        } catch (PartInitException e) {\r
-                                               Logger.defaultLogError(e);\r
+                                           LOGGER.error("Failed to open the graph editor", e);\r
                                        }\r
                                    }\r
                                });\r
diff --git a/bundles/org.simantics/src/org/simantics/Logger.java b/bundles/org.simantics/src/org/simantics/Logger.java
deleted file mode 100644 (file)
index 3001de3..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics;\r
-\r
-import java.util.Properties;\r
-\r
-import org.simantics.internal.Activator;\r
-\r
-\r
-\r
-public class Logger {\r
-    public static final boolean ECHO = true;\r
-    public static final Properties defaultProperties = new Properties();\r
-    static {\r
-        defaultProperties.put("log4j.rootCategory", "INFO, default");\r
-        defaultProperties.put("log4j.appender.default", "org.apache.log4j.FileAppender");\r
-        defaultProperties.put("log4j.appender.default.File", Activator.LOG_FILE_NAME);\r
-        defaultProperties.put("log4j.appender.default.append", "false");\r
-        defaultProperties.put("log4j.appender.default.layout", "org.apache.log4j.PatternLayout");\r
-        defaultProperties.put("log4j.appender.default.layout.ConversionPattern", "%d{ISO8601} %-6r [%15.15t] %-5p %30.30c - %m%n");\r
-    }\r
-    private static LogManager defaultLogManager = new LogManager(defaultProperties);\r
-    private static final Logger defaultErrorLogger = new Logger(LogManager.class);\r
-    private org.apache.log4j.Logger logger;\r
-    Logger(Class<?> clazz) {\r
-       logger = defaultLogManager.getLogger(clazz);\r
-    }\r
-\r
-    /**\r
-     * Log a trace event.\r
-     * \r
-     * @param message message of the trace\r
-     * @param exception the exception, or <code>null</code>\r
-     */\r
-    public void logTrace(String message, Throwable exception) {\r
-        // Errors are much more useful with a stack trace!\r
-        if (exception == null) {\r
-            exception = new RuntimeException();\r
-        }\r
-        logger.trace(message, exception);\r
-    }\r
-\r
-    /**\r
-     * Log an info event.\r
-     * \r
-     * @param message message of the info\r
-     * @param exception the exception, or <code>null</code>\r
-     */\r
-    public void logInfo(String message, Throwable exception) {\r
-        // Errors are much more useful with a stack trace!\r
-        if (exception == null) {\r
-            exception = new RuntimeException();\r
-        }\r
-        logger.info(message, exception);\r
-    }\r
-\r
-    /**\r
-     * Log a warning event.\r
-     * \r
-     * @param message message of the warning\r
-     * @param exception the exception, or <code>null</code>\r
-     */\r
-    public void logWarning(String message, Throwable exception) {\r
-        // Errors are much more useful with a stack trace!\r
-        if (exception == null) {\r
-            exception = new RuntimeException();\r
-        }\r
-        logger.warn(message, exception);\r
-    }\r
-\r
-    /**\r
-     * Log an error event.\r
-     * \r
-     * @param message message of the error\r
-     * @param exception the exception, or <code>null</code>\r
-     */\r
-    public void logError(String message, Throwable exception) {\r
-        // Errors are much more useful with a stack trace!\r
-        if (exception == null) {\r
-            exception = new RuntimeException();\r
-        }\r
-        logger.error(message, exception);\r
-    }\r
-\r
-    public static Logger getDefault() {\r
-        return defaultErrorLogger;\r
-    }\r
-    \r
-    public static LogManager getDefaultLogManager() {\r
-        return defaultLogManager;\r
-    }\r
-    public static void defaultLogError(Throwable exception) {\r
-        getDefault().logError(exception.getLocalizedMessage(), exception);\r
-        if(ECHO) exception.printStackTrace();\r
-    }\r
-    public static void defaultLogError(String message) {\r
-        getDefault().logError(message, null);\r
-        if(ECHO)\r
-            System.err.println(message);\r
-    }\r
-    public static void defaultLogError(String message, Throwable exception) {\r
-        getDefault().logError(message, exception);\r
-        if(ECHO)\r
-            System.err.println(message);\r
-    }\r
-    public static void defaultLogInfo(String message) {\r
-        getDefault().logInfo(message, null);\r
-        if(ECHO)\r
-            System.err.println(message);\r
-    }\r
-    public static void defaultLogTrace(String message) {\r
-        getDefault().logTrace(message, null);\r
-        if(ECHO)\r
-            System.err.println(message);\r
-    }\r
-    \r
-}\r
index 50110cb0375b51232cd78860b6a91ac5e96e0a28..daa9e7e10afd49e250767e29822d8f749eb166cd 100644 (file)
@@ -56,6 +56,8 @@ import org.simantics.utils.FileService;
 import org.simantics.utils.FileUtils;\r
 import org.simantics.utils.TempFiles;\r
 import org.simantics.utils.threads.ThreadUtils;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
 \r
 /**\r
  * A facade for accessing basic Simantics platform services. Usable without a\r
@@ -67,6 +69,7 @@ import org.simantics.utils.threads.ThreadUtils;
  * TODO: duplicate of org.simantics.db.layer0.util.Simantics, do something about this!!\r
  */\r
 public class Simantics {\r
+    private static final Logger LOGGER = LoggerFactory.getLogger(Simantics.class);\r
 \r
     /**\r
      * Default database driver ID\r
@@ -440,7 +443,7 @@ public class Simantics {
         try {\r
             IndexUtils.flushIndexCaches(progress, session);\r
         } catch (Exception e) {\r
-            Logger.defaultLogError(e);\r
+            LOGGER.error("Flushing index caches failed.", e);\r
         }\r
     }\r
 \r
index d59fff9c2fa85de2ef1afb2eab3e18bbd8a16f12..09d632a3edce942d288a44d8f1b8a19d51cda9c6 100644 (file)
@@ -103,6 +103,7 @@ import org.simantics.project.management.WorkspaceUtil;
 import org.simantics.utils.FileUtils;
 import org.simantics.utils.datastructures.Pair;
 import org.simantics.utils.logging.TimeLogger;
+import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
@@ -131,7 +132,7 @@ import org.slf4j.LoggerFactory;
  */
 public class SimanticsPlatform implements LifecycleListener {
 
-    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(SimanticsPlatform.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(SimanticsPlatform.class);
     
     /**
      * The policy is relevant when developing Simantics from Eclipse IDE.
@@ -768,7 +769,7 @@ public class SimanticsPlatform implements LifecycleListener {
             });
             TimeLogger.log("Flushed queries");
         } catch (DatabaseException e) {
-            Logger.defaultLogError(e);
+            LOGGER.error("Flushing queries failed.", e);
         }
         boolean loadProject = true;
         try {
@@ -809,7 +810,7 @@ public class SimanticsPlatform implements LifecycleListener {
             }
 
         } catch (DatabaseException e) {
-            Logger.defaultLogError(e);
+            LOGGER.error("Platform startup failed.", e);
             throw new PlatformException(e);
         } catch (ProjectException e) {
             boolean hasStackTrace = e.getStackTrace().length > 0;
@@ -931,7 +932,7 @@ public class SimanticsPlatform implements LifecycleListener {
                     try {
                         Simantics.flushIndexCaches(progress.newChild(20), s);
                     } catch (Throwable t) {
-                        Logger.defaultLogError(t);
+                        LOGGER.error("Failed to flush index caches.", t);
                     }
                 }
 
@@ -972,7 +973,7 @@ public class SimanticsPlatform implements LifecycleListener {
             if (null != databasebManagement)
                 databasebManagement.shutdown();
         } catch (Throwable t) {
-            Logger.defaultLogError(t);
+            LOGGER.error("Database shutdown failed.", t);
         }
         progress.worked(10);
 
@@ -980,7 +981,7 @@ public class SimanticsPlatform implements LifecycleListener {
         try {
             Simantics.clearTemporaryDirectory();
         } catch (Throwable t) {
-            Logger.defaultLogError(t);
+            LOGGER.error("Failed to clear the temporary directory.", t);
         }
         progress.worked(10);
         if (null != platformException)