]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Replace System.err and System.out with SLF4J Logging 86/1386/2
authorjsimomaa <jani.simomaa@gmail.com>
Wed, 17 Jan 2018 09:22:13 +0000 (11:22 +0200)
committerjsimomaa <jani.simomaa@gmail.com>
Fri, 19 Jan 2018 10:32:12 +0000 (12:32 +0200)
refs #7719

Change-Id: Iae42f94b542b17bc2e1aa839f506a6e1a46928ae

101 files changed:
bundles/org.simantics.acorn/src/org/simantics/acorn/ClusterManager.java
bundles/org.simantics.acorn/src/org/simantics/acorn/FileIO.java
bundles/org.simantics.acorn/src/org/simantics/acorn/GraphClientImpl2.java
bundles/org.simantics.acorn/src/org/simantics/acorn/lru/ChangeSetInfo.java
bundles/org.simantics.acorn/src/org/simantics/acorn/lru/ClusterInfo.java
bundles/org.simantics.acorn/src/org/simantics/acorn/lru/ClusterLRU.java
bundles/org.simantics.acorn/src/org/simantics/acorn/lru/ClusterStreamChunk.java
bundles/org.simantics.acorn/src/org/simantics/acorn/lru/FileInfo.java
bundles/org.simantics.acorn/src/org/simantics/acorn/lru/LRU.java
bundles/org.simantics.acorn/src/org/simantics/acorn/lru/LRUObject.java
bundles/org.simantics.annotation.ui/src/org/simantics/annotation/ui/SCL.java
bundles/org.simantics.browsing.ui.common/META-INF/MANIFEST.MF
bundles/org.simantics.browsing.ui.common/src/org/simantics/browsing/ui/common/internal/GENodeQueryManager.java
bundles/org.simantics.browsing.ui.graph.impl/META-INF/MANIFEST.MF
bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/ArrayPropertyLabelerFactory.java
bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/Evaluators.java
bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/GraphLabelerFactory.java
bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/LazyGraphLabeler.java
bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/PropertyValueRepresentationLabelerFactory.java
bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/RelationContextLabelerFactory.java
bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/StringRepresentationLabelerFactory.java
bundles/org.simantics.browsing.ui.model/META-INF/MANIFEST.MF
bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/browsecontexts/BrowseContext.java
bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/labeldecorators/ConstantLabelDecorationRule.java
bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/nodetypes/SpecialNodeType.java
bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/tests/InstanceOfTest.java
bundles/org.simantics.g2d/META-INF/MANIFEST.MF
bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/DiagramUtils.java
bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/TerminalPainter.java
bundles/org.simantics.g2d/src/org/simantics/g2d/dnd/DragPainter.java
bundles/org.simantics.g2d/src/org/simantics/g2d/gallery/GalleryViewer.java
bundles/org.simantics.g2d/src/org/simantics/g2d/participant/MultitouchPanZoomRotateInteractor.java
bundles/org.simantics.graph/src/org/simantics/graph/representation/TransferableGraphFileReader.java
bundles/org.simantics.issues.common/src/org/simantics/issues/common/DependencyIssueSource2.java
bundles/org.simantics.issues.common/src/org/simantics/issues/common/DependencyIssueSynchronizer2.java
bundles/org.simantics.issues.common/src/org/simantics/issues/common/DependencyIssueValidator2.java
bundles/org.simantics.issues.common/src/org/simantics/issues/common/IssueSourceUtils.java
bundles/org.simantics.mapping/META-INF/MANIFEST.MF
bundles/org.simantics.mapping/src/org/simantics/mapping/rule/instructions/QueryRuleInstruction.java
bundles/org.simantics.message/META-INF/MANIFEST.MF
bundles/org.simantics.message/src/org/simantics/message/internal/MessageSchemeManager.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/MergeFlagsHandler.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/ModelEvaluators.java
bundles/org.simantics.modeling/src/org/simantics/modeling/CompilePGraphs.java
bundles/org.simantics.modeling/src/org/simantics/modeling/PartialIC.java
bundles/org.simantics.modeling/src/org/simantics/modeling/SCLTypeUtils.java
bundles/org.simantics.modeling/src/org/simantics/modeling/UserComponentMigration.java
bundles/org.simantics.modeling/src/org/simantics/modeling/migration/DocumentCleanupMigrationStep.java
bundles/org.simantics.modeling/src/org/simantics/modeling/rules/MappedModelingRules.java
bundles/org.simantics.modeling/src/org/simantics/modeling/scl/RouteGraphMatching.java
bundles/org.simantics.modeling/src/org/simantics/modeling/services/CaseInsensitiveComponentFunctionNamingStrategy.java
bundles/org.simantics.modeling/src/org/simantics/modeling/services/CaseInsensitiveComponentNamingStrategy.java
bundles/org.simantics.modeling/src/org/simantics/modeling/services/CaseInsensitiveComponentNamingStrategy2.java
bundles/org.simantics.modeling/src/org/simantics/modeling/userComponent/ComponentTypeCommands.java
bundles/org.simantics.project/src/org/simantics/project/management/PlatformUtil.java
bundles/org.simantics.scenegraph.loader/META-INF/MANIFEST.MF
bundles/org.simantics.scenegraph.loader/src/org/simantics/scenegraph/loader/ScenegraphLoaderUtils.java
bundles/org.simantics.scenegraph/src/com/infomatiq/jsi/PriorityQueue.java
bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/SVGNode.java
bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/provisional/GraphPropertyNode.java
bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/utils/MipMapVRamBufferedImage.java
bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/utils/NodeUtil.java
bundles/org.simantics.scl.commands/META-INF/MANIFEST.MF
bundles/org.simantics.scl.commands/src/org/simantics/scl/commands/internal/serialization/CommandSerializerFactory.java
bundles/org.simantics.scl.commands/src/org/simantics/scl/commands/internal/serialization/ErrorSerializer.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/references/ValRef.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/utils/SSAValidationContext.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/types/TVarAst.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/markdown/html/SCLDocumentationExtensionNodeHandler.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/parser/generator/table/ParseTableBuilder.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/parser/grammar/Grammar.java
bundles/org.simantics.scl.reflection/META-INF/MANIFEST.MF
bundles/org.simantics.scl.reflection/src/org/simantics/scl/reflection/internal/Activator.java
bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/reporting/SCLReporting.java
bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/reporting/SCLReportingHandler.java
bundles/org.simantics.scl.ui/META-INF/MANIFEST.MF
bundles/org.simantics.scl.ui/plugin.xml
bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/AbstractCommandConsole.java
bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/SCLConsole.java
bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/outline/SCLModuleOutlinePage.java [new file with mode: 0644]
bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetReferenceResolver.java
bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/SpreadsheetSynchronizationEventHandler.java
bundles/org.simantics.structural.synchronization.client/META-INF/MANIFEST.MF
bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ReferenceResolverBase.java
bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/SynchronizationEventHandlerBase.java
bundles/org.simantics.structural.synchronization/META-INF/MANIFEST.MF
bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/utils/DiagnosticSynchronizationEventHandler.java
bundles/org.simantics.structural2/src/org/simantics/structural2/variables/StandardProceduralChildVariable.java
bundles/org.simantics.trend/META-INF/MANIFEST.MF
bundles/org.simantics.trend/src/org/simantics/trend/impl/ItemNode.java
bundles/org.simantics.ui/src/org/simantics/ui/jobs/SessionGarbageCollectorJob.java
bundles/org.simantics.ui/src/org/simantics/ui/workbench/WorkbenchShutdownServiceImpl.java
bundles/org.simantics.utils.thread/META-INF/MANIFEST.MF
bundles/org.simantics.utils.thread/src/org/simantics/utils/threads/ThreadUtils.java
bundles/org.simantics.utils.ui/META-INF/MANIFEST.MF
bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/widgets/TrackedStyledText.java
bundles/org.simantics.utils/src/org/simantics/utils/Development.java
tests/org.simantics.scl.compiler.tests/META-INF/MANIFEST.MF
tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/MemoryLeakExperiment.java
tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/TestCommandSession.java
tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/TestExpressionEvaluator.java

index 9725ffe8da2df0aabb169b301b955642781205dd..85daddd22af6d178154c3fcbaa7d3b756b61d894 100644 (file)
@@ -158,7 +158,7 @@ public class ClusterManager {
                                String fileName = parts[0] + "." + parts[1] + ".cluster";
                                Path from = dbFolder.resolve(readDirName).resolve(fileName);
                                Path to = baseline.resolve(fileName);
-                               System.err.println("purge copies " + from + "  => " + to);
+                               LOGGER.info("purge copies " + from + "  => " + to);
                                Files.copy(from, to, StandardCopyOption.COPY_ATTRIBUTES);
                                long first = new BigInteger(parts[0], 16).longValue();
                                long second = new BigInteger(parts[1], 16).longValue();
@@ -175,7 +175,7 @@ public class ClusterManager {
                                String fileName = parts[0] + ".extFile";
                                Path from = dbFolder.resolve(readDirName).resolve(fileName);
                                Path to = baseline.resolve(fileName);
-                               System.err.println("purge copies " + from + "  => " + to);
+                               LOGGER.info("purge copies " + from + "  => " + to);
                                Files.copy(from, to, StandardCopyOption.COPY_ATTRIBUTES);
                                FileInfo info = fileLRU.getWithoutMutex(parts[0]);
                                info.moveTo(baseline);
@@ -187,7 +187,7 @@ public class ClusterManager {
                        String readDirName = parts[1];
                        if(!readDirName.equals(currentDir)) {
                                ClusterStreamChunk chunk = streamLRU.purge(parts[0]);
-                               System.err.println("purge removes " + chunk);
+                               LOGGER.info("purge removes " + chunk);
                        }
                }
                
@@ -198,7 +198,7 @@ public class ClusterManager {
                        if(!readDirName.equals(currentDir)) {
                                Long revisionId = Long.parseLong(parts[0]);
                                ChangeSetInfo info = csLRU.purge(revisionId);
-                               System.err.println("purge removes " + info);
+                               LOGGER.info("purge removes " + info);
                        }
 //                     Path readDir = dbFolder.resolve(parts[1]);
 //                     Long revisionId = Long.parseLong(parts[0]);
@@ -232,7 +232,7 @@ public class ClusterManager {
        void tryPurgeDirectory(Path f) {
                
                
-               System.err.println("purge deletes " + f);
+               LOGGER.info("purge deletes " + f);
 
                String currentDir = f.getFileName().toString();
                if(currentDir.endsWith("db"))
@@ -243,7 +243,7 @@ public class ClusterManager {
 
                int ordinal = Integer.parseInt(currentDir);
                if(ordinal < mainState.headDir - 1) {
-                       System.err.println("purge deletes " + f);
+                       LOGGER.info("purge deletes " + f);
                        FileUtils.deleteDir(f.toFile());
                }
                
@@ -255,7 +255,7 @@ public class ClusterManager {
                throw cause;
                // Maximum autosave frequency is per 60s
                if(!fullSave && System.nanoTime() - lastSnapshot < 10*1000000000L) {
-    //             System.err.println("lastSnapshot too early");
+    //             LOGGER.info("lastSnapshot too early");
                    return false;
                }
     
@@ -370,10 +370,10 @@ public class ClusterManager {
 //                     e.printStackTrace();
 //             }
 
-               // System.err.println("-- load statistics --");
+               // LOGGER.info("-- load statistics --");
                // for(Pair<ClusterUID, Integer> entry :
                // CollectionUtils.valueSortedEntries(histogram)) {
-               // System.err.println(" " + entry.second + " " + entry.first);
+               // LOGGER.info(" " + entry.second + " " + entry.first);
                // }
 
 //     }
@@ -464,7 +464,7 @@ public class ClusterManager {
                }
                // Files
                for (String fileKey : state.files) {
-    //                 System.err.println("loadFile: " + fileKey);
+    //                 LOGGER.info("loadFile: " + fileKey);
                        String[] parts = fileKey.split("#");
                        Path readDir = dbFolder.resolve(parts[1]);
                        int offset = Integer.parseInt(parts[2]);
@@ -474,7 +474,7 @@ public class ClusterManager {
                }
                // Update chunks
                for (String fileKey : state.stream) {
-    //                 System.err.println("loadStream: " + fileKey);
+    //                 LOGGER.info("loadStream: " + fileKey);
                        String[] parts = fileKey.split("#");
                        Path readDir = dbFolder.resolve(parts[1]);
                        int offset = Integer.parseInt(parts[2]);
index c5480d86ec6c636233b5e5b21d8d5e688f319966..8f3009afab3f82b84c23156775efd901a925c1ae 100644 (file)
@@ -19,9 +19,12 @@ import java.util.Map;
 import java.util.Set;
 
 import org.simantics.databoard.file.RuntimeIOException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class FileIO {
-       
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(FileIO.class);
     private static final FileAttribute<?>[] NO_ATTRIBUTES = new FileAttribute[0];
     
     private static final Set<OpenOption> CREATE_OPTIONS = new HashSet<>(2);
@@ -71,7 +74,7 @@ public class FileIO {
             if(TRACE_PERF) {
                 long duration = System.nanoTime()-start;
                 double ds = 1e-9*duration;
-                System.err.println("Wrote " + bytes.length + " bytes @ " + 1e-6*bytes.length / ds + "MB/s");
+                LOGGER.info("Wrote " + bytes.length + " bytes @ " + 1e-6*bytes.length / ds + "MB/s");
             }
             return result;
                } catch (Throwable t) {
@@ -90,11 +93,11 @@ public class FileIO {
             }
             byte[] result = buf.array();
             if (result.length != length)
-                System.err.println("faa");
+                LOGGER.info("result length does not match expected {} {} {}", this, result.length, length);
             if (TRACE_PERF) {
                 long duration = System.nanoTime() - start;
                 double ds = 1e-9 * duration;
-                System.err.println("Read " + result.length + " bytes @ " + 1e-6 * result.length / ds + "MB/s");
+                LOGGER.info("Read " + result.length + " bytes @ " + 1e-6 * result.length / ds + "MB/s");
             }
             return result;
         }
@@ -135,10 +138,10 @@ public class FileIO {
                
                syncPath(test);
                
-               long duration = System.nanoTime()-s;
-               System.err.println("Took " + 1e-6*duration + "ms.");
-               
-               
+               if (LOGGER.isDebugEnabled()) {
+               long duration = System.nanoTime()-s;
+               LOGGER.info("Took " + 1e-6*duration + "ms.");
+               }
        }
        
 }
index 07fe18e61201cc16fd4e62bd62b808d8d6b5041d..09929f775b728ab02a9f808d5b3576d7cb1a6cd2 100644 (file)
@@ -200,7 +200,7 @@ public class GraphClientImpl2 implements Database.Session {
                                boolean executorTerminated = executor.awaitTermination(500, TimeUnit.MILLISECONDS);
                                boolean saverTerminated = saver.awaitTermination(500, TimeUnit.MILLISECONDS);
                                
-                               System.err.println("executorTerminated=" + executorTerminated + ", saverTerminated=" + saverTerminated);
+                               LOGGER.info("executorTerminated=" + executorTerminated + ", saverTerminated=" + saverTerminated);
 
                                try {
                                        clusters.mainState.save(dbFolder);
@@ -631,7 +631,7 @@ public class GraphClientImpl2 implements Database.Session {
                                final int changeSetId = clusters.state.headChangeSetId;
                                
                                if(ClusterUpdateProcessorBase.DEBUG)
-                                       System.err.println(" === BEGIN UNDO ===");
+                                       LOGGER.info(" === BEGIN UNDO ===");
                                
                                for(int i=0;i<changeSetIds.length;i++) {
                                        final long id = changeSetIds[changeSetIds.length-1-i];
@@ -641,7 +641,7 @@ public class GraphClientImpl2 implements Database.Session {
                                                String ccsid = ccss.get(ccss.size()-j-1);
                                                try {
                                                        if(ClusterUpdateProcessorBase.DEBUG)
-                                                               System.err.println("performUndo " + ccsid);
+                                                               LOGGER.info("performUndo " + ccsid);
                                                        performUndo(ccsid, clusterChanges, support);
                                                } catch (DatabaseException e) {
                                                        e.printStackTrace();
@@ -650,7 +650,7 @@ public class GraphClientImpl2 implements Database.Session {
                                }
                    
                                if(ClusterUpdateProcessorBase.DEBUG)
-                                       System.err.println(" === END UNDO ===");
+                                       LOGGER.info(" === END UNDO ===");
                    
                                for(int i=0;i<clusterChanges.size();i++) {
                                        
index a19a8540b48d3faafcf002541a622032046396a8..e1915d32b771aba4e7e1f5109f6be07d83d6b948 100644 (file)
@@ -8,11 +8,14 @@ import org.simantics.acorn.exception.AcornAccessVerificationException;
 import org.simantics.acorn.exception.IllegalAcornStateException;
 import org.simantics.db.service.Bytes;
 import org.simantics.utils.datastructures.Pair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import gnu.trove.list.array.TByteArrayList;
 
 public class ChangeSetInfo extends LRUObject<Long, ChangeSetInfo> {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(ChangeSetInfo.class);
        private byte[] metadataBytes;
        private ArrayList<String> clusterChangeSetIds;
        
@@ -110,4 +113,8 @@ public class ChangeSetInfo extends LRUObject<Long, ChangeSetInfo> {
                return false;
        }
 
+       @Override
+       public Logger getLogger() {
+           return LOGGER;
+       }
 }
\ No newline at end of file
index f20b384569d2c9893e7a3999756cd3308409ab2b..54689394d2e894e30ea0139fbed4aa78dfff237c 100644 (file)
@@ -20,9 +20,12 @@ import org.simantics.db.exception.SDBException;
 import org.simantics.db.service.Bytes;
 import org.simantics.db.service.ClusterUID;
 import org.simantics.utils.datastructures.Pair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class ClusterInfo extends LRUObject<ClusterUID, ClusterInfo> implements Persistable {
-       
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(ClusterInfo.class);
        final private ClusterManager manager;
        private ClusterImpl cluster;
        public int changeSetId;
@@ -328,7 +331,8 @@ public class ClusterInfo extends LRUObject<ClusterUID, ClusterInfo> implements P
                        long start = System.nanoTime();
                        state.waitForUpdates();
                        long duration = System.nanoTime() - start;
-                       System.err.println("Wait updates to cluster " + getKey() + " for " + (1e-6 * duration) + "ms.");
+                       if (LOGGER.isDebugEnabled())
+                           LOGGER.debug("Wait updates to cluster " + getKey() + " for " + (1e-6 * duration) + "ms.");
                }
        }
        
@@ -336,5 +340,9 @@ public class ClusterInfo extends LRUObject<ClusterUID, ClusterInfo> implements P
        protected boolean overwrite() {
                return true;
        }
-       
+
+       @Override
+       public Logger getLogger() {
+           return LOGGER;
+       }
 }
\ No newline at end of file
index ecc016723a6000f12bfec0e1dad9697d633c625d..e94abf7f208379efbc739a212a7338a545e5babe 100644 (file)
@@ -15,12 +15,15 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.impl.ClusterBase;
 import org.simantics.db.impl.ClusterI;
 import org.simantics.db.service.ClusterUID;
+import org.slf4j.LoggerFactory;
 
 import gnu.trove.map.hash.TIntIntHashMap;
 
 
 public class ClusterLRU extends LRU<ClusterUID, ClusterInfo> {
 
+    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(ClusterLRU.class);
+    
        final private BijectionMap<ClusterUID, Integer> clusterMapping = new BijectionMap<ClusterUID, Integer>();
        
        public ClusterLRU(ClusterManager manager, String identifier, Path writeDir) {
@@ -284,7 +287,7 @@ public class ClusterLRU extends LRU<ClusterUID, ClusterInfo> {
                                                        synchronized(map) {
                                                                value = map.get(key);
                                                                if(key != value) {
-                                                                       System.err.println("Read failed for real " + key + " vs. " + value);
+                                                                       LOGGER.warn("Read failed for real " + key + " vs. " + value);
                                                                }
                                                                //ws.release();
                                                        }
@@ -302,9 +305,10 @@ public class ClusterLRU extends LRU<ClusterUID, ClusterInfo> {
                write.join();
                read.join();
                
-               long duration = System.nanoTime() - start;
-               System.err.println("took " + 1e-9*duration + "s.");
-               
+               if (LOGGER.isDebugEnabled()) {
+                   long duration = System.nanoTime() - start;
+                   LOGGER.debug("took " + 1e-9*duration + "s.");
+               }
        }
        
 }
index 57d6f6a04b5d387c2c0b31ca2fd6cafab845dd4c..12d4d55b8cb20f92b79721d76d8df5ba3061ab3b 100644 (file)
@@ -16,11 +16,14 @@ import org.simantics.compressions.Compressions;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.service.Bytes;
 import org.simantics.utils.datastructures.Pair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import gnu.trove.list.array.TByteArrayList;
 
 public class ClusterStreamChunk extends LRUObject<String, ClusterStreamChunk> implements Persistable {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(ClusterStreamChunk.class);
        // 500KB is a fine chunk
        private static int MAX_CHUNK_SIZE = 500*1024;
 
@@ -296,5 +299,9 @@ public class ClusterStreamChunk extends LRUObject<String, ClusterStreamChunk> im
        protected boolean overwrite() {
                return false;
        }
-       
+
+       @Override
+       public Logger getLogger() {
+           return LOGGER;
+       }
 }
\ No newline at end of file
index 116464727c55cceb44500b740880c9912d1ca373..0e1367f9954ee2f2aad677f7d89bd0b86fda620b 100644 (file)
@@ -6,11 +6,14 @@ import org.simantics.acorn.exception.AcornAccessVerificationException;
 import org.simantics.acorn.exception.IllegalAcornStateException;
 import org.simantics.db.Database.Session.ResourceSegment;
 import org.simantics.utils.datastructures.Pair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import gnu.trove.list.array.TByteArrayList;
 
 public class FileInfo extends LRUObject<String, FileInfo> {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(FileInfo.class);
        private TByteArrayList bytes;
        
        // Stub
@@ -125,4 +128,8 @@ public class FileInfo extends LRUObject<String, FileInfo> {
                return true;
        }
 
+       @Override
+       public Logger getLogger() {
+           return LOGGER;
+       }
 }
\ No newline at end of file
index 48b7d4b10a9b34c80e9a68c7b536ef3840e48867..b9ba72121858540c66e7c40d66990f196ecc7cea 100644 (file)
@@ -62,7 +62,7 @@ public class LRU<MapKey,MapValue extends LRUObject<MapKey, MapValue>> {
        public void acquireMutex() throws IllegalAcornStateException {
                try {
                        while(!mutex.tryAcquire(3, TimeUnit.SECONDS)) {
-                               System.err.println("Mutex is taking a long time to acquire - owner is " + mutexOwner);
+                               LOGGER.info("Mutex is taking a long time to acquire - owner is " + mutexOwner);
                        }
                        if(VERIFY)
                                mutexOwner = Thread.currentThread();
@@ -78,7 +78,7 @@ public class LRU<MapKey,MapValue extends LRUObject<MapKey, MapValue>> {
 
        public void shutdown() {
            if (GraphClientImpl2.DEBUG)
-               System.err.println("Shutting down LRU writers " + writers);
+               LOGGER.info("Shutting down LRU writers " + writers);
                writers.shutdown();
                try {
                        writers.awaitTermination(60, TimeUnit.SECONDS);
@@ -97,7 +97,7 @@ public class LRU<MapKey,MapValue extends LRUObject<MapKey, MapValue>> {
                        }
                });
                if (GraphClientImpl2.DEBUG)
-                   System.err.println("Resuming LRU writers " + writers);
+                   LOGGER.info("Resuming LRU writers " + writers);
        }
 
        /*
index 508c951067dedc3df895d938b3a0e84f9dda771c..a84a281089c289de2dbad32cd5dce6db359453ea 100644 (file)
@@ -10,9 +10,11 @@ import org.simantics.acorn.Persistable;
 import org.simantics.acorn.exception.AcornAccessVerificationException;
 import org.simantics.acorn.exception.IllegalAcornStateException;
 import org.simantics.utils.datastructures.Pair;
+import org.slf4j.Logger;
 
 public abstract class LRUObject<MapKey, MapValue extends LRUObject<MapKey, MapValue>> implements Persistable {
-       
+
+    public abstract Logger getLogger();
        public static boolean VERIFY = true;
        
        // Final stuff
@@ -64,7 +66,7 @@ public abstract class LRUObject<MapKey, MapValue extends LRUObject<MapKey, MapVa
        public void acquireMutex() throws IllegalAcornStateException {
                try {
                        while(!mutex.tryAcquire(3, TimeUnit.SECONDS)) {
-                               System.err.println("Mutex is taking a long time to acquire - owner is " + mutexOwner);
+                               getLogger().info("Mutex is taking a long time to acquire - owner is " + mutexOwner);
                        }
                        
                        if(VERIFY)
index 44f9f23fd0594aafe69855de38d7c920e4774260..688e92ca52dba505572db4b4940738838bc7e689 100644 (file)
@@ -701,7 +701,7 @@ public class SCL {
                    if(var != null) {
                        map.put(name, var);
                    } else {
-                       System.err.println("No adapter for " + child + " in " + context.getURI(graph));
+                       LOGGER.warn("No adapter for " + child + " in " + context.getURI(graph));
                    }
                }
                return map;
index 96c9447962aba91ef00da9acf990f59e3edcb9ab..4da99a1260a8210d2b1681de5f13b5186a1ef8fb 100644 (file)
@@ -10,7 +10,8 @@ Require-Bundle: org.simantics.browsing.ui;bundle-version="[0.9.0,2.0.0)";visibil
  org.eclipse.jface;bundle-version="3.6.0",
  org.simantics.ui;bundle-version="1.0.0",
  org.simantics.databoard;bundle-version="0.6.2",
- org.simantics.common;bundle-version="1.0.0"
+ org.simantics.common;bundle-version="1.0.0",
+ org.slf4j.api
 Export-Package: org.simantics.browsing.ui.common,
  org.simantics.browsing.ui.common.comparators,
  org.simantics.browsing.ui.common.contributor,
index 43b9d3bb253df135ceacc51c67e1ecb81a2d42f0..6921a3b2fab092a171ade1b348b65614ec5f987c 100644 (file)
@@ -28,9 +28,11 @@ import org.simantics.browsing.ui.PrimitiveQueryUpdater;
 import org.simantics.browsing.ui.common.internal.IGECache.IGECacheEntry;
 import org.simantics.browsing.ui.exception.NoDataSourceException;
 import org.simantics.browsing.ui.exception.NoQueryProcessorException;
+import org.slf4j.LoggerFactory;
 
 public class GENodeQueryManager implements NodeQueryManager, PrimitiveQueryUpdater {
 
+    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(GENodeQueryManager.class);
     private static final boolean DEBUG = false;
 
     protected IGraphExplorerContext ge;
@@ -50,8 +52,8 @@ public class GENodeQueryManager implements NodeQueryManager, PrimitiveQueryUpdat
 
     void queryDebug(String s) {
         for (int i = 0; i < ge.queryIndent(); ++i)
-            System.err.append("   ");
-        System.err.println(s);
+            LOGGER.info("   ");
+        LOGGER.info(s);
     }
 
     String toString(UIElementReference ref) {
index d15789960a7f1ba10154625aff93826ab52547d9..beb73b45f4f950ed7077c0f249d48273962c5fff 100644 (file)
@@ -12,7 +12,8 @@ Require-Bundle: org.simantics.browsing.ui.common;bundle-version="[0.9.0,2.0.0)",
  org.simantics.db.management;bundle-version="0.8.0",
  org.eclipse.ui;bundle-version="3.6.0",
  org.simantics.browsing.ui.model;bundle-version="1.0.0",
- org.simantics.ui;bundle-version="1.0.0"
+ org.simantics.ui;bundle-version="1.0.0",
+ org.slf4j.api
 Export-Package: org.simantics.browsing.ui.graph.impl,
  org.simantics.browsing.ui.graph.impl.contribution,
  org.simantics.browsing.ui.graph.impl.contributor.imager,
index 77f141a2f8e5a87a47c59843691c8da8d59c5b4f..b41679b83fdfb6dc247647f370465c84a85ec120 100644 (file)
@@ -42,6 +42,8 @@ import org.simantics.db.management.ISessionContext;
 import org.simantics.layer0.Layer0;
 import org.simantics.utils.datastructures.ArrayMap;
 import org.simantics.utils.datastructures.slice.ValueRange;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * @author Tuukka Lehtonen
@@ -151,6 +153,12 @@ public class ArrayPropertyLabelerFactory implements LabelerFactory {
             }
             return null;
         }
+
+        @Override
+        public Logger getLogger() {
+            // TODO Auto-generated method stub
+            return null;
+        }
     }
 
     static class ArrayPropertyLabeler extends LazyGraphLabeler {
@@ -262,6 +270,11 @@ public class ArrayPropertyLabelerFactory implements LabelerFactory {
             }
             return null;
         }
+
+        @Override
+        public Logger getLogger() {
+            return LoggerFactory.getLogger(ArrayPropertyLabeler.class);
+        }
     };
 
 }
index b0e09381fb351108321409da8e3c7e6286d2716b..e86cdc54703559214895694478c386a6cf80e9f3 100644 (file)
@@ -66,6 +66,8 @@ import org.simantics.db.Resource;
 import org.simantics.db.common.request.ReadRequest;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.exception.ResourceNotFoundException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * An entry point for loading an EvaluatorData in a data-oriented fashion. Also
@@ -75,6 +77,7 @@ import org.simantics.db.exception.ResourceNotFoundException;
  */
 public class Evaluators {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(Evaluators.class);
     public static final boolean DEBUG = false;
 
     public static void create(EvaluatorData data, final ResourceManager resourceManager,
@@ -293,12 +296,8 @@ public class Evaluators {
                     for(String browseContext : browseContexts) {
                         try {
                             browseContextResources.add(graph.getResource(browseContext));
-                        } catch(ResourceNotFoundException e) {
-                            // Expected result, if no modelled contributions exist.
-                            //System.err.println("Didn't find " + browseContext + " while loading model browser.");
                         } catch(DatabaseException e) {
-                            System.err.println("Didn't find " + browseContext + " while loading model browser.");
-                            e.printStackTrace();
+                            LOGGER.error("Didn't find " + browseContext + " while loading model browser.", e);
                         }
                     }
 
index 0671286e7a28632ff4bd514ed4e6a1e364e0e66f..4ed616fd9f70720238cda2874ac5f609093a4286 100644 (file)
@@ -24,6 +24,8 @@ import org.simantics.browsing.ui.content.Labeler.Modifier;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.exception.DatabaseException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public abstract class GraphLabelerFactory implements LabelerFactory {
 
@@ -53,6 +55,11 @@ public abstract class GraphLabelerFactory implements LabelerFactory {
             public Modifier getModifier(ModificationContext modificationContext, String key) {
                return GraphLabelerFactory.this.getModifier(key);
             }
+
+            @Override
+            public Logger getLogger() {
+                return LoggerFactory.getLogger(GraphLabelerFactory.class);
+            }
             
         };
     }
index cf410444ed7753fc9a4d6df73882211fdc811f9e..a7635bedfbb676c337870027bcb85550494766e5 100644 (file)
@@ -25,6 +25,7 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.procedure.Listener;
 import org.simantics.utils.ui.ErrorLogger;
+import org.slf4j.Logger;
 
 public abstract class LazyGraphLabeler extends LabelerStub {
 
@@ -80,8 +81,7 @@ public abstract class LazyGraphLabeler extends LabelerStub {
 
             @Override
             public void exception(Throwable t) {
-                System.err.println("LazyGraphLabeler2: ");
-                t.printStackTrace();
+                getLogger().error("LazyGraphLabeler2: ", t);
             }
 
         };
@@ -116,4 +116,5 @@ public abstract class LazyGraphLabeler extends LabelerStub {
 
     }
 
+    public abstract Logger getLogger();
 }
index 2b63c1a4f4de372e586ced9ba047ee88a532acda..bb24e710ccdc0b478b0600392bfee56854e04133 100644 (file)
@@ -29,6 +29,8 @@ import org.simantics.db.Resource;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.management.ISessionContext;
 import org.simantics.utils.datastructures.ArrayMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Requires {@link IProperty} as input.
@@ -77,6 +79,12 @@ public class PropertyValueRepresentationLabelerFactory implements LabelerFactory
                 }
                 return null;
             }
+            
+            @Override
+            public Logger getLogger() {
+                return LoggerFactory.getLogger(getClass());
+            }
+
         };
     }
 
index 6bb04490aff9a9b7136cccac2e52c8769b5b0bd9..d9c9ca8fbc4bcaf5fec58fc12405fd86ebcad99a 100644 (file)
@@ -24,6 +24,8 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.RelationContext;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.utils.datastructures.ArrayMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * @author Tuukka Lehtonen
@@ -46,6 +48,11 @@ public class RelationContextLabelerFactory implements LabelerFactory {
                     object = LabelerUtil.safeStringRepresentation(graph, ctx.getStatement().getObject());
                 return ArrayMap.make(ColumnKeys.KEYS_PROPERTY_VALUE, new String[] { property, object });
             }
+
+            @Override
+            public Logger getLogger() {
+                return LoggerFactory.getLogger(RelationContextLabelerFactory.class);
+            }
         };
     }
 
index 506e737d54c319ce170c6266391c7ef2edc1ca1e..bec550ff32da944ea964103987b5e4fcc8636d45 100644 (file)
@@ -28,6 +28,8 @@ import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.management.ISessionContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class StringRepresentationLabelerFactory implements LabelerFactory {
 
@@ -75,6 +77,11 @@ public class StringRepresentationLabelerFactory implements LabelerFactory {
                 }
                 return null;
             }
+
+            @Override
+            public Logger getLogger() {
+                return LoggerFactory.getLogger(StringRepresentationLabelerFactory.class);
+            }
         };
     }
 
index 7367b15df5d743605fc357d2bb5a51c30a1dfdbe..2562611bb2ff4eb5bde75da98e7ff8dc636d0dde 100644 (file)
@@ -10,7 +10,8 @@ Require-Bundle: org.simantics.browsing.ui.common;bundle-version="1.1.0",
  gnu.trove3;bundle-version="3.0.3",
  org.simantics.graphviz;bundle-version="1.1.0",
  org.simantics.graphviz.ui;bundle-version="1.1.0",
- org.simantics.ui;bundle-version="1.0.0"
+ org.simantics.ui;bundle-version="1.0.0",
+ org.slf4j.api
 Export-Package: org.simantics.browsing.ui.model,
  org.simantics.browsing.ui.model.actions,
  org.simantics.browsing.ui.model.browsecontexts,
index 8e5bf73c7ee88f565f9c3cfab585cd798400b37c..e57bfacca92d11b8b71d7eba4b2a8f1e0aa4c8e1 100644 (file)
@@ -68,6 +68,8 @@ import org.simantics.graphviz.Node;
 import org.simantics.graphviz.ui.GraphvizComponent;
 import org.simantics.scl.reflection.OntologyVersions;
 import org.simantics.viewpoint.ontology.ViewpointResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * BrowseContext holds all contributions related to given set of browse contexts.
@@ -75,7 +77,8 @@ import org.simantics.viewpoint.ontology.ViewpointResource;
  * @author Hannu Niemistö
  */
 public class BrowseContext {
-       
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(BrowseContext.class);
        public static final boolean DEBUG = false;
        
     NodeTypeMultiMap<ChildContribution> childContributions = new NodeTypeMultiMap<ChildContribution>();
@@ -160,8 +163,7 @@ public class BrowseContext {
                     try {
                         browseContextResources.add(graph.getResource(browseContext));
                     } catch (ResourceNotFoundException e) {
-                        // Expected result, if no modelled contributions exist.
-                        //System.err.println("Didn't find " + browseContext + " while loading model browser.");
+                        LOGGER.error("Didn't find " + browseContext + " while loading model browser.", e);
                     }
                 }
                 Collection<Resource> allBrowseContextResources = BrowseContext.findSubcontexts(graph, browseContextResources);
@@ -222,9 +224,9 @@ public class BrowseContext {
                Collection<NodeContext> children = contribution.getChildren(graph, parent);
             result.addAll(children);
             if(DEBUG) {
-                   System.err.println("contribution: " + contribution.getIdentifier());
+                   LOGGER.info("contribution: " + contribution.getIdentifier());
                    for(NodeContext ctx : children)
-                       System.err.println("-" + ctx);
+                       LOGGER.info("-" + ctx);
             }
         }
         
index 2df8e52ee93ca8e98b1b85e9ba5655e0e6c57197..5ba9ced6ed3fa07ca9ae71f96e8661818cb00044 100644 (file)
@@ -22,6 +22,8 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.viewpoint.ontology.ViewpointResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Constant label decoration rule decorates the label in a fixed way.
@@ -29,6 +31,7 @@ import org.simantics.viewpoint.ontology.ViewpointResource;
  */
 public class ConstantLabelDecorationRule extends AbstractLabelDecorator implements LabelDecorationRule {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(ConstantLabelDecorationRule.class);
     /**
      * For headless instances where no Display is available
      */
@@ -69,7 +72,7 @@ public class ConstantLabelDecorationRule extends AbstractLabelDecorator implemen
                     this.style |= SWT.ITALIC;
                     break;
                 default:
-                    System.err.println("Invalid character '" + c + "' in style string. Only B and I recognized.");
+                   LOGGER.info("Invalid character '" + c + "' in style string. Only B and I recognized.");
                 }
     }
 
index ddd6113ff57ca77ee6f0e08ca0a7f54ec4836ebf..8218bac41e2e23327e3a5fa83d0166efbbf5e618 100644 (file)
@@ -26,8 +26,13 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.variable.Variable;
 import org.simantics.ui.selection.WorkbenchSelectionElement;
 import org.simantics.viewpoint.ontology.ViewpointResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class SpecialNodeType implements NodeType {
+    
+    private static final Logger LOGGER = LoggerFactory.getLogger(SpecialNodeType.class);
+    
     public Resource resource;
     Class<?> contentType;
     
@@ -55,17 +60,19 @@ public class SpecialNodeType implements NodeType {
                     if (bundleId != null) {
                         bundle = Platform.getBundle(bundleId);
                         if (bundle == null)
-                            System.err.println("Referenced bundle '" + bundleId + "' not found in platform.");
+                            LOGGER.warn("Referenced bundle '" + bundleId + "' not found in platform.");
                     }
                     if (bundle != null)
                         contentType = bundle.loadClass(contentTypeName);
                     else
                         contentType = Class.forName(contentTypeName);
                 } catch (ClassNotFoundException e) {
-                    System.err.println("Unknown content type " + contentTypeName);
+                    LOGGER.error("Unknown content type {} - {}", contentTypeName, e.getMessage());
+                    if (LOGGER.isTraceEnabled())
+                        LOGGER.trace("Unknown content type {}", contentTypeName, e);
                 }
             else
-                System.err.println("Content type is NULL.");
+                LOGGER.warn("Content type is NULL.");
         }
         return new SpecialNodeType(r, contentType);
     }
index 70b6ecaa419854896a7d09675c1f3ea2bdd7a72e..08888911319a36b37240f600ef4e66575049f5f8 100644 (file)
@@ -7,6 +7,8 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.viewpoint.ontology.ViewpointResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * A visual contribution rule test that checks whether the input content is an
@@ -17,6 +19,7 @@ import org.simantics.viewpoint.ontology.ViewpointResource;
  */
 public class InstanceOfTest implements Test {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(InstanceOfTest.class);
     String   bundleName;
     String   className;
     Class<?> clazz;
@@ -40,7 +43,7 @@ public class InstanceOfTest implements Test {
             return clazz;
         Bundle b = Platform.getBundle(bundleName);
         if (b == null) {
-            System.err.println(getClass() + " could not resolve class " + className + ", bundle " + bundleName + " not found in platform");
+            LOGGER.error(getClass() + " could not resolve class " + className + ", bundle " + bundleName + " not found in platform");
             failed = true;
             return null;
         }
@@ -48,7 +51,7 @@ public class InstanceOfTest implements Test {
             this.clazz = b.loadClass(className);
             return clazz;
         } catch (ClassNotFoundException e) {
-            System.err.println(getClass() + " could not resolve class " + className + ", from bundle " + bundleName);
+            LOGGER.error(getClass() + " could not resolve class " + className + ", from bundle " + bundleName, e);
             failed = true;
             return null;
         }
index f5ed551cca6c884930b20e07ea441e6005b88b4c..0a6fd2a0adbe38fa4dad5eda9200ead3fe666432 100644 (file)
@@ -20,7 +20,8 @@ Require-Bundle: org.eclipse.core.runtime,
  org.simantics.databoard;bundle-version="0.6.5",
  org.simantics.datatypes;bundle-version="1.0.0",
  org.simantics.db;bundle-version="1.1.0",
- org.simantics.ui;bundle-version="1.0.0"
+ org.simantics.ui;bundle-version="1.0.0",
+ org.slf4j.api
 Export-Package: org.simantics.g2d.canvas,
  org.simantics.g2d.canvas.impl,
  org.simantics.g2d.chassis,
index ed812c21a556aa7517a38bd5778e474decbb9bdf..8cfea8b59ee46dab4cb2f72f174a338d3d4208e9 100644 (file)
@@ -58,6 +58,8 @@ import org.simantics.g2d.routing.IConnection;
 import org.simantics.g2d.routing.IRouter2;
 import org.simantics.g2d.routing.TrivialRouter2;
 import org.simantics.scenegraph.utils.GeometryUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import gnu.trove.map.hash.THashMap;
 
@@ -68,6 +70,7 @@ import gnu.trove.map.hash.THashMap;
  */
 public class DiagramUtils {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(DiagramUtils.class);
     /**
      * Get rectangle that contains all elements or null if there are no elements.
      * @param d
@@ -157,7 +160,7 @@ public class DiagramUtils {
 
         for (final IElement element : elementsToFix) {
             if (!d.containsElement(element)) {
-                System.err.println("Fixing element not contained by diagram " + d + ": " + element);
+                LOGGER.warn("Fixing element not contained by diagram " + d + ": " + element);
                 continue;
             }
 
index e4c7ac2011e0b0dcf2a70f29dd9dc800e8593a22..39baa912c6cfc99724aaa09b6c40a57b543af020 100644 (file)
@@ -43,6 +43,8 @@ import org.simantics.utils.datastructures.hints.IHintListener;
 import org.simantics.utils.datastructures.hints.IHintObservable;
 import org.simantics.utils.datastructures.hints.IHintContext.Key;
 import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Paints terminals of elements.
@@ -51,6 +53,7 @@ import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;
  */
 public class TerminalPainter extends AbstractDiagramParticipant {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(TerminalPainter.class);
     public static final int PAINT_PRIORITY = ElementPainter.ELEMENT_PAINT_PRIORITY + 10;
 
     public interface TerminalHoverStrategy {
@@ -196,7 +199,7 @@ public class TerminalPainter extends AbstractDiagramParticipant {
 
                 AffineTransform invTx = util.getInverseTransform();
                 if (invTx == null) {
-                    System.err.println("NO CANVAS TRANSFORM INVERSE AVAILABLE, CANVAS TRANSFORM IS: " + util.getTransform());
+                    LOGGER.warn("NO CANVAS TRANSFORM INVERSE AVAILABLE, CANVAS TRANSFORM IS: " + util.getTransform());
                     return;
                 }
 
index 3ebccf136a158e8fd9295f4cb9fe6a89f37b0059..feb712cd31865f107166cb487cd798161e0b6e40 100644 (file)
@@ -31,6 +31,8 @@ import org.simantics.scenegraph.g2d.nodes.SingleElementNode;
 import org.simantics.scenegraph.g2d.snap.ISnapAdvisor;
 import org.simantics.utils.datastructures.context.IContext;
 import org.simantics.utils.datastructures.context.IContextListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * This participant paints an array of icons of a drag operation.
@@ -38,6 +40,7 @@ import org.simantics.utils.datastructures.context.IContextListener;
  * @author Toni Kalajainen
  */
 public class DragPainter extends AbstractCanvasParticipant {
+    private static final Logger LOGGER = LoggerFactory.getLogger(DragPainter.class);
     // Priority of drag event, eats ecs key
     public final static int DRAG_EVENT_PRIORITY = Integer.MAX_VALUE - 1500;
     public final static int DRAG_PAINT_PRIORITY = Integer.MAX_VALUE - 1100;
@@ -188,7 +191,7 @@ public class DragPainter extends AbstractCanvasParticipant {
 
                 IG2DNode itemHolder = node.getNode(""+item.hashCode());
                 if (itemHolder != null && !(itemHolder instanceof SingleElementNode)) {
-                    System.err.println("BUG: item hash codes collide within the dragged item context - found unrecognized item " + itemHolder + " with node id '" + item.hashCode() + "'");
+                    LOGGER.error("BUG: item hash codes collide within the dragged item context - found unrecognized item " + itemHolder + " with node id '" + item.hashCode() + "'");
                     continue;
                 }
 
index 08ccf1f8769104812bd28e42f2d3ae5fec9699ab..2e8ad5b66f434345ef03e435a5440bb409403fb2 100644 (file)
@@ -103,6 +103,8 @@ import org.simantics.utils.threads.SWTThread;
 import org.simantics.utils.threads.ThreadUtils;
 import org.simantics.utils.threads.logger.ITask;
 import org.simantics.utils.threads.logger.ThreadLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * @author Toni Kalajainen <toni.kalajainen@vtt.fi>
@@ -110,6 +112,7 @@ import org.simantics.utils.threads.logger.ThreadLogger;
  */
 public class GalleryViewer extends ContentViewer {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(GalleryViewer.class);
     /**
      * A hint key for storing a GalleryViewer within the hint stack of
      * {@link GalleryViewer}'s {@link ICanvasContext}.
@@ -598,7 +601,7 @@ public class GalleryViewer extends ContentViewer {
      */
     void refreshElementSizes() {
         if (awtComponent == null) {
-            System.err.println("GalleryViewer.refreshElementSizes: awtComponent is null");
+            LOGGER.error("GalleryViewer.refreshElementSizes: awtComponent is null");
             return;
         }
 
index 3e1f625b8fc1d8f534e9c1c008418b4f5aac20e8..95cd9c029c1df6a409a247154c7db07747068b01 100644 (file)
@@ -138,7 +138,7 @@ public class MultitouchPanZoomRotateInteractor extends AbstractCanvasParticipant
         double t_y = b1_y - s_x * a1_y - s_y * a1_x;
         
         double mat[] = new double[] {s_x, s_y, -s_y, s_x, t_x, t_y};
-        AffineTransform at = new AffineTransform(mat);        
+        AffineTransform at = new AffineTransform(mat);
                setDirty();
         
         AffineTransform gat = util.getTransform();
index 7f4cc3e9b03216074e1ed31fd09073e4ceb50098..ae1ec711ce676e9d3932cbbbc10485601cbb2f1d 100644 (file)
@@ -18,10 +18,14 @@ import org.simantics.databoard.container.DataContainers;
 import org.simantics.databoard.serialization.RuntimeSerializerConstructionException;
 import org.simantics.databoard.serialization.Serializer;
 import org.simantics.databoard.type.Datatype;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 final public class TransferableGraphFileReader extends ByteFileReader {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(TransferableGraphFileReader.class);
+
        InputStream in = new InputStream() {
 
         @Override
@@ -68,7 +72,7 @@ final public class TransferableGraphFileReader extends ByteFileReader {
                        int pos = dst.position();
                        int limit = dst.limit();
                        int i=stream.read(dst.array(), pos, limit-pos);
-                       //System.err.println("Read " + i + " (expected " + dst.array().length + ")");
+                       //LOGGER.warn("Read " + i + " (expected " + dst.array().length + ")");
                        return i;
                }
                
@@ -164,11 +168,11 @@ final public class TransferableGraphFileReader extends ByteFileReader {
                int identities = safeInt();
                Identity[] ids = new Identity[identities];
 
-//             System.err.println("rc: " + resourceCount);
-//             System.err.println("ids: " + identities);
+//             LOGGER.warn("rc: " + resourceCount);
+//             LOGGER.warn("ids: " + identities);
                
 //             long duration = System.nanoTime() - start;
-//             System.err.println("start in " + 1e-9*duration + "s.");
+//             LOGGER.warn("start in " + 1e-9*duration + "s.");
 //             start = System.nanoTime();
                
                for(int i=0;i<identities;i++) {
@@ -215,15 +219,15 @@ final public class TransferableGraphFileReader extends ByteFileReader {
 
                }
 
-//             for(Identity id : ids) System.err.println("id: " + id);
+//             for(Identity id : ids) LOGGER.warn("id: " + id);
 
                
 //             duration = System.nanoTime() - start;
-//             System.err.println("ids in " + 1e-9*duration + "s.");
+//             LOGGER.warn("ids in " + 1e-9*duration + "s.");
 //             start = System.nanoTime();
 
                int stmLength = safeInt();
-//             System.err.println("statements: " + stmLength + " (" + byteIndex + ")");
+//             LOGGER.warn("statements: " + stmLength + " (" + byteIndex + ")");
                
                int[] statements = new int[stmLength];
 
@@ -242,12 +246,12 @@ final public class TransferableGraphFileReader extends ByteFileReader {
                }
 
 //             duration = System.nanoTime() - start;
-//             System.err.println("stms in " + 1e-9*duration + "s.");
+//             LOGGER.warn("stms in " + 1e-9*duration + "s.");
 //             
 //             start = System.nanoTime();
 
                int valueLength = safeInt();
-//             System.err.println("values: " + valueLength + " (" + byteIndex + ")");
+//             LOGGER.warn("values: " + valueLength + " (" + byteIndex + ")");
 
                Value[] values = new Value[valueLength]; 
 
@@ -262,13 +266,13 @@ final public class TransferableGraphFileReader extends ByteFileReader {
                                .deserialize((DataInput)dis, idcontext);
                        values[i] = new Value(resource, value);
                        
-                       //System.err.println("read variant[" + resource + "]: " + value.toString().substring(0, Math.min(100, value.toString().length())));
+                       //LOGGER.warn("read variant[" + resource + "]: " + value.toString().substring(0, Math.min(100, value.toString().length())));
                        
                }
 
                
 //             duration = System.nanoTime() - start;
-//             System.err.println("values in " + 1e-9*duration + "s.");
+//             LOGGER.warn("values in " + 1e-9*duration + "s.");
                
                return new TransferableGraph1(resourceCount, ids, statements, values, extensions.map);
 
@@ -284,7 +288,7 @@ final public class TransferableGraphFileReader extends ByteFileReader {
                        long s = System.nanoTime();
                        reader.readTG();
                        long d = System.nanoTime() - s;
-                       System.err.println("Duration=" + 1e-9*d + "s.");
+                       LOGGER.warn("Duration=" + 1e-9*d + "s.");
                        
                        
                } catch (Throwable t) {
index b11fd220ddff588650af40c443d00c017336e9a8..73bc047bd475f67f42d456275606550b4758d457 100644 (file)
@@ -28,9 +28,12 @@ import org.simantics.issues.ontology.IssueResource;
 import org.simantics.layer0.Layer0;
 import org.simantics.scl.runtime.function.Function2;
 import org.simantics.simulation.ontology.SimulationResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class DependencyIssueSource2 implements IssueSource {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(DependencyIssueSource2.class);
        public static final boolean DEBUG = false;
        
        private Resource source;
@@ -63,7 +66,7 @@ public class DependencyIssueSource2 implements IssueSource {
                HashSet<Resource> depSet = new HashSet<>();
 
                if(DEBUG) {
-                       System.err.println("resourcesToCheck[" + NameUtils.getSafeName(graph, source) + "] - component changes for type " + NameUtils.getSafeName(graph, searchTypes));
+                       LOGGER.info("resourcesToCheck[" + NameUtils.getSafeName(graph, source) + "] - component changes for type " + NameUtils.getSafeName(graph, searchTypes));
                }
 
                depSet.addAll(IssueSourceUtils.getChangedDependencies(graph, model, base, searchTypes, event));
@@ -72,9 +75,9 @@ public class DependencyIssueSource2 implements IssueSource {
                List<Resource> deps = new ArrayList<>(depSet);
                
                if(DEBUG) {
-                       System.err.println("resourcesToCheck[" + NameUtils.getSafeName(graph, source) + "] " + deps);
+                       LOGGER.info("resourcesToCheck[" + NameUtils.getSafeName(graph, source) + "] " + deps);
                        for(Resource r : deps) {
-                               System.err.println("dep " + NameUtils.getSafeName(graph, r));
+                               LOGGER.info("dep " + NameUtils.getSafeName(graph, r));
                        }
                }
                
@@ -88,7 +91,7 @@ public class DependencyIssueSource2 implements IssueSource {
 
                if(DEBUG) {
                        for(Resource r : deps) {
-                               System.err.println("dep extension " + NameUtils.getSafeName(graph, r));
+                               LOGGER.info("dep extension " + NameUtils.getSafeName(graph, r));
                        }
                }
                
index 1cb22d57453b46853154ef234de345475d3d285e..e31d5027e18cc605a12487716227bdd08f723be9 100644 (file)
@@ -15,9 +15,12 @@ import org.simantics.issues.common.DependencyIssueValidator2.Contexts;
 import org.simantics.issues.common.DependencyIssueValidator2.DependencyIssueDescriptions;
 import org.simantics.issues.ontology.IssueResource;
 import org.simantics.layer0.Layer0;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class DependencyIssueSynchronizer2 extends WriteRequest {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(DependencyIssueSynchronizer2.class);
        public static final boolean DEBUG = false;
        
        private Resource resource;
@@ -31,7 +34,7 @@ public class DependencyIssueSynchronizer2 extends WriteRequest {
        @Override
        public void perform(WriteGraph graph) throws DatabaseException {
 
-               if(DEBUG) System.err.println("Running DependencySynchronizer for " + resource);
+               if(DEBUG) LOGGER.info("Running DependencySynchronizer for " + resource);
 
                Set<Issue> existing = graph.syncRequest(new DependencyIssueDescriptions(source, resource), TransientCacheListener.<Set<Issue>>instance());
                Set<Issue> contexts = Collections.emptySet();
index 68905e57dff42142a6eb8002d099c34d620fcef7..13e4961b30ff5b6edf6c411a011d2c053873733d 100644 (file)
@@ -64,7 +64,7 @@ public class DependencyIssueValidator2 extends ResourceRead3<Boolean> {
                        try {
                                @SuppressWarnings("unchecked")
                                Set<Issue> contexts = new HashSet<Issue>((List<Issue>)Functions.exec(graph, function, graph, resource2));
-                       if(DEBUG) System.err.println("Validator found: " + contexts.size() + " issues (" + contexts + ")");
+                       if(DEBUG) LOGGER.info("Validator found: " + contexts.size() + " issues (" + contexts + ")");
                        return contexts;
                        } catch (DatabaseException e) {
                                LOGGER.error("Reading a constraint validator failed", e);
@@ -83,21 +83,21 @@ public class DependencyIssueValidator2 extends ResourceRead3<Boolean> {
        @Override
        public Boolean perform(ReadGraph graph) throws DatabaseException {
                
-               if(DEBUG) System.err.println("Running DependencyValidator for " + NameUtils.getSafeName(graph, resource) + " " +  NameUtils.getSafeName(graph, resource3));
+               if(DEBUG) LOGGER.info("Running DependencyValidator for " + NameUtils.getSafeName(graph, resource) + " " +  NameUtils.getSafeName(graph, resource3));
 
                Set<Issue> existing = graph.syncRequest(new DependencyIssueDescriptions(resource3, resource), TransientCacheListener.<Set<Issue>>instance());
 
-        if(DEBUG) System.err.println("Existing: " + existing.size() + " issues (" + existing + ")");
+        if(DEBUG) LOGGER.info("Existing: " + existing.size() + " issues (" + existing + ")");
                
                // Removed resources do not have issues
                if(!graph.hasStatement(resource)) {
-               if(DEBUG) System.err.println("No statements");
+               if(DEBUG) LOGGER.info("No statements");
                        return existing.isEmpty();
                }
 
         Set<Issue> contexts = graph.syncRequest(new Contexts(resource3, resource), TransientCacheListener.<Set<Issue>>instance());
 
-        if(DEBUG) System.err.println("Current: " + contexts.size() + " issues (" + contexts + ")");
+        if(DEBUG) LOGGER.info("Current: " + contexts.size() + " issues (" + contexts + ")");
         
                return existing.equals(contexts);
 
index f79e90a47e7b0c20df602a71924a5cab7a12722b..32de2780ac0f4448da0c419bba87dc75c6879495 100644 (file)
@@ -41,9 +41,12 @@ import org.simantics.db.service.CollectionSupport;
 import org.simantics.db.service.ManagementSupport;
 import org.simantics.db.service.VirtualGraphSupport;
 import org.simantics.issues.ontology.IssueResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class IssueSourceUtils {
-       
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(IssueSourceUtils.class);
        public static final boolean DEBUG = false;
        public static final boolean DEBUG_CHANGE_ENTRIES = false;
        public static final boolean DEBUG_RESOURCES = false;
@@ -68,7 +71,7 @@ public class IssueSourceUtils {
                                        IssueResource ISSUE = IssueResource.getInstance(graph);
                                        graph.claimLiteral(source, ISSUE.ContinuousIssueSource_lastUpdateRevision, headRevision, Bindings.LONG);
                                        if(DEBUG)
-                                               System.err.println("-update[" + NameUtils.getSafeName(graph, source) + "][" + headRevision + "]");
+                                               LOGGER.info("-update[" + NameUtils.getSafeName(graph, source) + "][" + headRevision + "]");
                                }
 
                        });
@@ -109,7 +112,7 @@ public class IssueSourceUtils {
                Collection<Resource> data = graph.syncRequest(new Test3(component, types), TransientCacheAsyncListener.<Collection<Resource>>instance());
                if(DEBUG_RESOURCES) {
                        for(Resource r : data) {
-                               System.err.println("IssueSourceUtils.test " + " " + NameUtils.getSafeName(graph, component) + " " + NameUtils.getSafeName(graph, types) + " " + NameUtils.getSafeName(graph, r));
+                               LOGGER.info("IssueSourceUtils.test " + " " + NameUtils.getSafeName(graph, component) + " " + NameUtils.getSafeName(graph, types) + " " + NameUtils.getSafeName(graph, r));
                        }
                }
                result.addAll(data);
@@ -134,7 +137,7 @@ public class IssueSourceUtils {
 
        public static void processChange(ReadGraph graph, Change c, ResourceSet types, Set<Resource> result) throws DatabaseException {
                if(DEBUG_CHANGE_ENTRIES)
-                       System.err.println("-processChange: " + c.toString(graph));
+                       LOGGER.info("-processChange: " + c.toString(graph));
                if(c instanceof ComponentAddition) {
                        ComponentAddition addition = (ComponentAddition)c;
                        test(graph, addition.component, types, result);
@@ -156,7 +159,7 @@ public class IssueSourceUtils {
                if(revisionId == null) revisionId = 0L;
 
                if(DEBUG)
-                       System.err.println("getChangedDependencies[" + NameUtils.getSafeName(graph, source) + "][" + revisionId + "]");
+                       LOGGER.info("getChangedDependencies[" + NameUtils.getSafeName(graph, source) + "][" + revisionId + "]");
                
                Map<Resource, Collection<Change>> index = MetadataUtils.getDependencyChangesFrom(graph, revisionId+1);
 
index 46c07ed2368e96746dc1a1c0afc5ab9343fa4352..8f584dca5322a2e274dab811b96a07664c70b088 100644 (file)
@@ -6,7 +6,8 @@ Bundle-Version: 1.1.0.qualifier
 Require-Bundle: gnu.trove3;bundle-version="3.0.3",
  org.simantics.layer0;bundle-version="1.0.0",
  org.simantics.layer0.utils;bundle-version="0.8.0",
- org.simantics.db.layer0;bundle-version="1.1.0"
+ org.simantics.db.layer0;bundle-version="1.1.0",
+ org.slf4j.api
 Export-Package: org.simantics.mapping,
  org.simantics.mapping.constraint,
  org.simantics.mapping.constraint.instructions,
index dbb0e7ca40459d7876bcc8d8f025d1ae9f7d7924..404df9c4871f625999c74858142d91835da56895 100644 (file)
  *******************************************************************************/
 package org.simantics.mapping.rule.instructions;
 
-import gnu.trove.map.hash.TIntIntHashMap;
-import gnu.trove.procedure.TIntProcedure;
-import gnu.trove.set.hash.TIntHashSet;
-
 import org.simantics.db.ReadGraph;
 import org.simantics.db.WriteGraph;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.request.Read;
 import org.simantics.layer0.utils.triggers.IModification;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import gnu.trove.map.hash.TIntIntHashMap;
+import gnu.trove.procedure.TIntProcedure;
+import gnu.trove.set.hash.TIntHashSet;
 
 public class QueryRuleInstruction implements IRuleInstruction {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(QueryRuleInstruction.class);
        IRuleInstruction rule;
        int[] variables;
        int workSpace;
@@ -92,7 +95,7 @@ public class QueryRuleInstruction implements IRuleInstruction {
                                if(parameter != null)
                                        result += parameter.hashCode();
                                else
-                                       System.err.println("Parameter is null!!!");
+                                       LOGGER.error("Parameter is null!!!");
                        }
                        return result;
                }
index 5789861bbc97e556c4e6986f84462c3e4895b1ef..355faba37167b88b14e05214937c079543af95c7 100644 (file)
@@ -6,7 +6,8 @@ Bundle-Version: 1.1.0.qualifier
 Bundle-Activator: org.simantics.message.internal.Activator
 Bundle-Vendor: Semantum Oy
 Require-Bundle: org.eclipse.core.runtime,
- org.simantics.db;bundle-version="[1.0.0,2.0.0)"
+ org.simantics.db;bundle-version="[1.0.0,2.0.0)",
+ org.slf4j.api
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Bundle-ActivationPolicy: lazy
 Export-Package: org.simantics.message,
index b9d62f53f68da1f33b442727861241a82f8bda51..13eb635d0eeb53be2c8898d2580160205e822ab7 100644 (file)
@@ -28,12 +28,15 @@ import org.eclipse.core.runtime.dynamichelpers.IExtensionTracker;
 import org.eclipse.core.runtime.dynamichelpers.IFilter;
 import org.simantics.message.IMessageDataSchemeExtension;
 import org.simantics.message.IMessageSchemeManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * @author Tuukka Lehtonen
  */
 public class MessageSchemeManager implements IExtensionChangeHandler, IMessageSchemeManager {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(MessageSchemeManager.class);
     public final static String           NAMESPACE    = "org.simantics.message";
     public final static String           ELEMENT_NAME = "scheme";
     public final static String           EP_NAME      = "messageDataScheme";
@@ -90,8 +93,7 @@ public class MessageSchemeManager implements IExtensionChangeHandler, IMessageSc
                     msg.append("\n  1st: " + ext.getSchemeElement().getContributor().getName());
                     msg.append("\n  2nd: " + el.getContributor().getName());
                     msg.append("\nUsing the first one.");
-                    // TODO: proper logging
-                    System.err.println(msg.toString());
+                    LOGGER.info(msg.toString());
                     continue;
                 }
 
@@ -120,8 +122,7 @@ public class MessageSchemeManager implements IExtensionChangeHandler, IMessageSc
                     StringBuilder msg = new StringBuilder();
                     msg.append("No scheme extension for message scheme id '" + id + "'. Ignoring handler '" + el.getAttribute("handler") + "'");
                     msg.append("\nUsing the first one.");
-                    // TODO: proper logging
-                    System.err.println(msg.toString());
+                    LOGGER.info(msg.toString());
                     continue;
                 }
 
@@ -133,8 +134,7 @@ public class MessageSchemeManager implements IExtensionChangeHandler, IMessageSc
                     msg.append("\n   1st: " + prev.getContributor().getName());
                     msg.append("\n   2nd: " + el.getContributor().getName());
                     msg.append("\nUsing the first one.");
-                    // TODO: proper logging
-                    System.err.println(msg.toString());
+                    LOGGER.info(msg.toString());
                     continue;
                 }
 
index a426915128b7734890066c63d071713dd3cac728..9a7b1055cd08fc90bd0ddec2208fa66131371ea0 100644 (file)
@@ -11,6 +11,8 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.diagram.synchronization.runtime.DiagramSelectionUpdater;
 import org.simantics.g2d.canvas.ICanvasContext;
 import org.simantics.modeling.flags.MergeFlags;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * @author Hannu Niemist&ouml;
@@ -18,6 +20,7 @@ import org.simantics.modeling.flags.MergeFlags;
  */
 public class MergeFlagsHandler extends FlagOperationHandler {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(MergeFlagsHandler.class);
     protected void perform(IProgressMonitor monitor, WriteGraph graph, List<Resource> flags, ICanvasContext canvasContext) throws DatabaseException {
         monitor.beginTask("Merge Selected Flags", IProgressMonitor.UNKNOWN);
         performMerge(graph, flags, canvasContext);
@@ -26,7 +29,7 @@ public class MergeFlagsHandler extends FlagOperationHandler {
     public static void performMerge(WriteGraph graph, List<Resource> flags, ICanvasContext canvasContext) throws DatabaseException {
         final String text = MergeFlags.validateForMerge(graph, flags);
         if(text != null) {
-            System.err.println(text);
+            LOGGER.error(text);
             PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
                 @Override
                 public void run() {
@@ -39,7 +42,7 @@ public class MergeFlagsHandler extends FlagOperationHandler {
         else {
             String result = MergeFlags.merge(graph, flags);
             if(result != null && !result.isEmpty()) {
-                System.err.println(result); // Should not happen because of prevalidation
+                LOGGER.error(result); // Should not happen because of prevalidation
             } else {
                 if (canvasContext != null) {
                     // Make sure the diagram selection is set to the
index 31a64fa48ae2086e9ee74db68af449d7041c433d..25e57286fd10c79efe9ff1575fb0a0f57ec325b8 100644 (file)
@@ -58,6 +58,8 @@ import org.simantics.modeling.ui.modelBrowser.model.INode2;
 import org.simantics.modeling.ui.modelBrowser.model.IUpdateable;
 import org.simantics.ui.SimanticsUI;
 import org.simantics.utils.datastructures.UnaryFunction;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * @author Hannu Niemist&ouml;
@@ -430,6 +432,11 @@ class NodeLabelerFactory implements LabelerFactory {
             public int category(ReadGraph graph) throws DatabaseException {
                 return ((INode) context.getConstant(BuiltinKeys.INPUT)).getCategory(graph);
             }
+
+            @Override
+            public Logger getLogger() {
+                return LoggerFactory.getLogger(NodeLabelerFactory.class);
+            }
         };
     }
 }
index 7f7171dca54a8b82ece8f27441e7d58c7079eb29..7781fbeffdbe9d90cafd4b8e01346f27984c1f31 100644 (file)
@@ -66,12 +66,15 @@ import org.simantics.ltk.Problem;
 import org.simantics.modeling.internal.Activator;
 import org.simantics.utils.FileUtils;
 import org.simantics.utils.datastructures.Pair;
+import org.slf4j.LoggerFactory;
 
 /**
  * @author Antti Villberg
  */
 public class CompilePGraphs {
 
+    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(CompilePGraphs.class);
+
     public static interface UserAgent {
         void reportProblems(CompilationResult result);
     }
@@ -149,6 +152,8 @@ public class CompilePGraphs {
                        if (name == null) name = id;
                        if (name.equals(thisOntology.first))
                                continue;
+                       if (name.contains("ModelBroker"))
+                           continue;
             URL tg = b.getEntry("/graph.tg");
             if (tg == null) continue;
             File f = url2file(FileLocator.resolve(tg), b.getSymbolicName());
@@ -287,7 +292,7 @@ public class CompilePGraphs {
                 Logger.defaultLogError(e);
             }
         } else {
-            System.err.println("Unsupported URL protocol '" + url + "' for FastLZ native library file '" + fileName);
+            LOGGER.warn("Unsupported URL protocol");
         }   
         return null;
     }
index a777f655e1650d5c4ddfa55cf3fe5f9e22fdd119..be5d86acc39738d6b34cae02266a909588095c89 100644 (file)
@@ -9,9 +9,12 @@ import org.simantics.db.WriteGraph;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.variable.RVI;
 import org.simantics.db.layer0.variable.Variable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class PartialIC {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(PartialIC.class);
        public static Binding BINDING = Bindings.getBindingUnchecked(PartialIC.class);
        
        public RVI[] rvis = {};
@@ -34,10 +37,10 @@ public class PartialIC {
 //                     Variant variant = entry.getValue();
 //                     Variable v = rvi.resolvePossible(graph, base);
 //                     if(v != null) {
-////                           System.err.println("apply " + v.getURI(graph) + " => " + variant);
+////                           LOGGER.warn("apply " + v.getURI(graph) + " => " + variant);
 //                             v.setValue(graph, variant.getValue(), variant.getBinding());
 //                     } else {
-//                             System.err.println("failed to resolve " + rvi);
+//                             LOGGER.warn("failed to resolve " + rvi);
 //                     }
 //             }
            
@@ -50,10 +53,10 @@ public class PartialIC {
                Variant variant = variants[i];
                Variable v = rvi.resolvePossible(graph, base);
                if (v != null) {
-//              System.err.println("apply " + v.getURI(graph) + " => " + variant);
+//              LOGGER.warn("apply " + v.getURI(graph) + " => " + variant);
                 v.setValue(graph, variant.getValue(), variant.getBinding());
             } else {
-                System.err.println("failed to resolve " + rvi);
+                LOGGER.warn("failed to resolve " + rvi);
             }
         }
            
index d3c7310e4ccf23c47350224f99fc0b3a45574082..c94b1be1b2dbaeb43c96b934d551024bb5d2be8a 100644 (file)
@@ -16,8 +16,11 @@ import org.simantics.scl.compiler.types.TCon;
 import org.simantics.scl.compiler.types.Type;
 import org.simantics.scl.compiler.types.Types;
 import org.simantics.scl.compiler.types.kinds.Kinds;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class SCLTypeUtils {
+    private static final Logger LOGGER = LoggerFactory.getLogger(SCLTypeUtils.class);
     private static final THashMap<String, Type> TYPE_MAP = new THashMap<String, Type>();
     
     private static void add(TCon type) {
@@ -68,7 +71,7 @@ public class SCLTypeUtils {
     public static Type getType(String typeText) {
         Type type = TYPE_MAP.get(typeText);
         if(type == null) {
-            System.err.println("SCLTypeUtils.getType cannot transform '" + typeText + "' to type. Returns a as default.");
+            LOGGER.warn("SCLTypeUtils.getType cannot transform '" + typeText + "' to type. Returns a as default.");
             return Types.var(Kinds.STAR);
         }
         return type;
@@ -92,7 +95,7 @@ public class SCLTypeUtils {
         else if(dataType instanceof ArrayType)
             return Types.list(getType(((ArrayType)dataType).componentType));
         else {
-            System.err.println("SCLTypeUtils.getType cannot transform data type '" + dataType + "' to type. Returns a as default.");
+            LOGGER.warn("SCLTypeUtils.getType cannot transform data type '" + dataType + "' to type. Returns a as default.");
             return Types.var(Kinds.STAR);
         }
     }
@@ -103,7 +106,7 @@ public class SCLTypeUtils {
         else if(propertyInfo.requiredDatatype != null)
             return getType(propertyInfo.requiredDatatype);
         else {
-            System.err.println(propertyInfo.name + " doesn't have type information. Returns a as default.");
+            LOGGER.warn(propertyInfo.name + " doesn't have type information. Returns a as default.");
             return Types.var(Kinds.STAR);
         }
     }
index be480be4785357e632310940c2d9948d860be4a5..928c405b5a5cb6e88d1eb4ab42ed6896e804d982 100644 (file)
@@ -45,6 +45,8 @@ import org.simantics.utils.datastructures.MapList;
 import org.simantics.utils.datastructures.Pair;
 import org.simantics.utils.datastructures.Triple;
 import org.simantics.utils.strings.AlphanumComparator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import gnu.trove.set.hash.THashSet;
 
@@ -54,6 +56,8 @@ import gnu.trove.set.hash.THashSet;
  */
 public class UserComponentMigration {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(UserComponentMigration.class);
+
     public static void migrateUserComponents(WriteGraph graph, Resource source, Resource target, Collection<Resource> components) throws DatabaseException {
         MigrateModel model = getComponentTypeModel(graph, source, target, null);
         if (model.instances.isEmpty())
@@ -206,7 +210,7 @@ public class UserComponentMigration {
             Resource type = graph.getPossibleType(instance, STR.Component);
             String uri = graph.getPossibleURI(instance);
             if (type == null || uri == null) {
-                System.err.println("CANNOT MIGRATE INSTANCE DUE TO TYPING PROBLEM: " + NameUtils.getURIOrSafeNameInternal(graph, instance));
+                LOGGER.warn("CANNOT MIGRATE INSTANCE DUE TO TYPING PROBLEM: " + NameUtils.getURIOrSafeNameInternal(graph, instance));
                 continue;
             }
             NamedResource best = matchBest(graph, type, targetOntology);
index 642434cc2bd87ac486e77d533871af10f6c81970..b9b1d1ac7e4198db5cb2986e6af711645661341e 100644 (file)
@@ -13,9 +13,13 @@ import org.simantics.db.layer0.util.RemoverUtil;
 import org.simantics.document.DocumentResource;
 import org.simantics.layer0.Layer0;
 import org.simantics.modeling.ModelingUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class DocumentCleanupMigrationStep implements MigrationStep {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(DocumentCleanupMigrationStep.class);
+
     @Override
     public void applyTo(IProgressMonitor monitor, Session session, MigrationState state) throws DatabaseException {
        
@@ -33,7 +37,7 @@ public class DocumentCleanupMigrationStep implements MigrationStep {
                for(Resource model : graph.getObjects(indexRoot, L0.ConsistsOf)) {
                                for(Resource instance : ModelingUtils.searchByType(graph, model, DOC.ScenegraphDocument)) {
                                        if(!graph.hasStatement(instance, DOC.HasDocumentation_Inverse)) {
-                                               System.err.println("Removing stray document " + graph.getURI(instance));
+                                               LOGGER.info("Removing stray document " + graph.getURI(instance));
                                                RemoverUtil.remove(graph, instance);
                                        }
                                }
index a47a1b63f580a80fc94b389d2557ee50b9238c94..21a435f4ab134aa26d920d93241e113badce0487 100644 (file)
@@ -36,9 +36,12 @@ import org.simantics.structural2.modelingRules.IAttachmentRelationMap;
 import org.simantics.structural2.modelingRules.IConnectionPoint;
 import org.simantics.structural2.modelingRules.IModelingRules;
 import org.simantics.structural2.modelingRules.Policy;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class MappedModelingRules extends AbstractModelingRules {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(MappedModelingRules.class);
     IModelingRules baseRules;
     IMapping mapping;
 
@@ -69,7 +72,7 @@ public class MappedModelingRules extends AbstractModelingRules {
         ModelingResources MOD = ModelingResources.getInstance(g);
 
         if(Policy.DEBUG_STANDARD_MODELING_RULES)
-            System.out.println("setConnectionType(" + NameUtils.getSafeName(g, connection) + ", " + NameUtils.getSafeName(g, connectionType) + ")");
+            LOGGER.info("setConnectionType(" + NameUtils.getSafeName(g, connection) + ", " + NameUtils.getSafeName(g, connectionType) + ")");
 
         RelatedDiagramConnections rdc = new RelatedDiagramConnections(g);
         rdc.addConnection(connection);
@@ -133,12 +136,12 @@ public class MappedModelingRules extends AbstractModelingRules {
             if(cp == null)
                 throw new IllegalArgumentException("Null connection point encountered.");
             if(Policy.DEBUG_STANDARD_MODELING_RULES)
-                System.out.println("Mapping CP: " + cp.toString(g));
+                LOGGER.info("Mapping CP: " + cp.toString(g));
             int mcps = mapping.mapToConnectionPoints(g, cp, mappedConnectionPoints);
             if(mcps > 0) {
                 if(Policy.DEBUG_STANDARD_MODELING_RULES)
                     for (IConnectionPoint mcpt : mappedConnectionPoints.subList(mappedConnectionPoints.size()-mcps, mappedConnectionPoints.size()))
-                        System.out.println("Mapped CP: " + mcpt.toString(g));
+                        LOGGER.info("Mapped CP: " + mcpt.toString(g));
             } else {
                 if(cp instanceof CPTerminal) {
                     // TODO move this logic elsewhere
@@ -211,7 +214,7 @@ public class MappedModelingRules extends AbstractModelingRules {
             Resource connection) throws DatabaseException {
         Resource mappedConnection = mapping.mapConnection(g, connection);
         if(mappedConnection == null)
-            System.err.println("Connection mapped from " + NameUtils.getSafeName(g, connection, true) + " is null");
+            LOGGER.warn("Connection mapped from " + NameUtils.getSafeName(g, connection, true) + " is null");
         return new MappedAttachmentRelationMap(
                 baseRules.getAttachmentRelations(g, mappedConnection)
         );
index b13ff6b755fd9168cf57563218ce1e10d34f1ec7..61eee5511b55c07049b0058d2c5e22f12517b031 100644 (file)
@@ -12,9 +12,12 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.diagram.stubs.DiagramResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class RouteGraphMatching {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(RouteGraphMatching.class);
     public static boolean TRACE = false;
     
     private static class Link {
@@ -69,7 +72,7 @@ public class RouteGraphMatching {
             }
             for(int i=0;i<result.length;++i)
                 if(result[i] == null) {
-                    System.err.println("Didn't resolve resource " + i + ".");
+                    LOGGER.warn("Didn't resolve resource " + i + ".");
                     printState();
                     return false;
                 }
@@ -94,24 +97,26 @@ public class RouteGraphMatching {
         }
 
         private void printState() {
+            StringBuilder sb = new StringBuilder();
             for(int i=0;i<result.length;++i) {
-                System.out.print("    {" + i + "} ");
+                sb.append("    {" + i + "} ");
                 if(result[i] != null)
-                    System.out.print(" = " + result[i].getResourceId());
+                    sb.append(" = " + result[i].getResourceId());
                 else if(alternatives[i] != null) {
-                    System.out.print(" in");
+                    sb.append(" in");
                     for(Resource r : alternatives[i])
-                        System.out.print(" " + r.getResourceId());
+                        sb.append(" " + r.getResourceId());
                 }
                 else
-                    System.out.print(" unknown");
+                    sb.append(" unknown");
                 if(!ls[i].isEmpty()) {
-                    System.out.print(", links to");
+                    sb.append(", links to");
                     for(Link l : ls[i])
-                        System.out.print(" " + (l.a==i ? l.b : l.a));
+                        sb.append(" " + (l.a==i ? l.b : l.a));
                 }
-                System.out.println();
+                sb.append('\n');
             }
+            LOGGER.info(sb.toString());
         }
 
         private boolean propagate(int pos) throws DatabaseException {
index 40115a1ac393c564017d21420dae13fe20302dea..feef9c8992fce52eec3e4417e45897762bf06b03 100644 (file)
@@ -32,9 +32,10 @@ import org.simantics.db.service.GraphChangeListenerSupport;
 import org.simantics.layer0.Layer0;
 import org.simantics.scl.runtime.function.Function;
 import org.simantics.scl.runtime.function.Function1;
-import org.simantics.scl.runtime.tuple.Tuple3;
 import org.simantics.scl.runtime.tuple.Tuple4;
 import org.simantics.structural.stubs.StructuralResource2;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import gnu.trove.set.hash.THashSet;
 
@@ -52,6 +53,7 @@ import gnu.trove.set.hash.THashSet;
  */
 public class CaseInsensitiveComponentFunctionNamingStrategy extends ComponentNamingStrategyBase {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(CaseInsensitiveComponentFunctionNamingStrategy.class);
     protected static final boolean                                  DEBUG_INDEX_SEARCH = false | DEBUG_ALL;
 
     @SuppressWarnings("rawtypes")
@@ -140,7 +142,7 @@ public class CaseInsensitiveComponentFunctionNamingStrategy extends ComponentNam
                         Set<Resource> rs = new THashSet<Resource>();
                         for (Resource componentResult : components) {
                             if (DEBUG_INDEX_SEARCH)
-                                System.out.println(getClass().getSimpleName() + ": found " + componentResult);
+                                LOGGER.info(getClass().getSimpleName() + ": found " + componentResult);
                             String n = graph.getPossibleRelatedValue(componentResult, L0.HasName, Bindings.STRING);
                             if (n != null && n.toLowerCase().equals(lowercaseName))
                                rs.add(componentResult);
@@ -194,13 +196,13 @@ public class CaseInsensitiveComponentFunctionNamingStrategy extends ComponentNam
             Layer0 L0 = Layer0.getInstance(graph);
             for (Resource componentResult : components) {
                 if (DEBUG_INDEX_SEARCH)
-                    System.out.println(getClass().getSimpleName() + ": found " + componentResult);
+                    LOGGER.info(getClass().getSimpleName() + ": found " + componentResult);
                 String name = graph.getPossibleRelatedValue(componentResult, L0.HasName, Bindings.STRING);
                 if (name != null)
                     reserved.add(name);
             }
             
-            System.err.println("found " + reserved.size() + " components");
+            LOGGER.warn("found " + reserved.size() + " components");
             
             return reserved;
 
@@ -213,7 +215,7 @@ public class CaseInsensitiveComponentFunctionNamingStrategy extends ComponentNam
             Resource componentType, String proposition, boolean acceptProposition) throws NamingException, DatabaseException {
         Resource indexRoot = graph.syncRequest(new PossibleIndexRoot(configurationRoot));
         if (indexRoot == null) {
-            System.err.println("Could not find index root from configuration root '" + NameUtils.getSafeName(graph, configurationRoot, true) + "'");
+            LOGGER.warn("Could not find index root from configuration root '" + NameUtils.getSafeName(graph, configurationRoot, true) + "'");
             if(fallbackStrategy == null)
                 fallbackStrategy = 
                     new CaseInsensitiveComponentNamingStrategy2(graph.getService(GraphChangeListenerSupport.class), generatedNameFormat);
@@ -237,7 +239,7 @@ public class CaseInsensitiveComponentFunctionNamingStrategy extends ComponentNam
             cache.addRequested(result);
 
             if (DEBUG_INDEX_SEARCH)
-                System.out.println(getClass().getSimpleName() + ": validated instance name " + result);
+                LOGGER.info(getClass().getSimpleName() + ": validated instance name " + result);
 
             return result;
         }
@@ -270,14 +272,14 @@ public class CaseInsensitiveComponentFunctionNamingStrategy extends ComponentNam
                 List<Resource> components = (List<Resource>) index.apply(graph, indexRoot, search, Integer.MAX_VALUE);
 
                 if (DEBUG_INDEX_SEARCH)
-                    System.out.println(getClass().getSimpleName() + ": found " + components.size()
+                    LOGGER.info(getClass().getSimpleName() + ": found " + components.size()
                             + " index results for index root " + indexRoot + " & configurationRoot " + configurationRoot
                             + " & proposition '" + proposition + "':");
 
                 reserved.clear();
                 for (Resource componentResult : components) {
                     if (DEBUG_INDEX_SEARCH)
-                        System.out.println(getClass().getSimpleName() + ": found " + componentResult);
+                        LOGGER.info(getClass().getSimpleName() + ": found " + componentResult);
                     String name = graph.getPossibleRelatedValue(componentResult, L0.HasName, Bindings.STRING);
                     if (name != null)
                         reserved.add(name);
@@ -291,11 +293,11 @@ public class CaseInsensitiveComponentFunctionNamingStrategy extends ComponentNam
                 result.add(name);
 
                 if (DEBUG_INDEX_SEARCH)
-                    System.out.println(getClass().getSimpleName() + ": validated instance name " + proposition + " -> " + name);
+                    LOGGER.info(getClass().getSimpleName() + ": validated instance name " + proposition + " -> " + name);
             }
 
             if (DEBUG_INDEX_SEARCH)
-                System.out.println(getClass().getSimpleName() + ": validated instance names " + propositions + " -> " + result);
+                LOGGER.info(getClass().getSimpleName() + ": validated instance names " + propositions + " -> " + result);
 
             return result;
         }
index ff1c17bd36c72da78f14561218d0d858a772a00d..d2c15b5c47e98780d10dba480a1eaa9d20715fb7 100644 (file)
@@ -43,6 +43,8 @@ import org.simantics.modeling.ComponentUtils;
 import org.simantics.structural.stubs.StructuralResource2;
 import org.simantics.utils.datastructures.Pair;
 import org.simantics.utils.ui.ErrorLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * A first-hand component naming strategy implementation for structural models.
@@ -58,6 +60,7 @@ import org.simantics.utils.ui.ErrorLogger;
  */
 public class CaseInsensitiveComponentNamingStrategy extends ComponentNamingStrategyBase implements ChangeListener {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(CaseInsensitiveComponentNamingStrategy.class);
     private static final boolean            DEBUG_ALL                                     = false;
     private static final boolean            DEBUG_GRAPH_UPDATES                           = false | DEBUG_ALL;
     private static final boolean            DEBUG_CACHE_INITIALIZATION                    = false | DEBUG_ALL;
@@ -139,7 +142,7 @@ public class CaseInsensitiveComponentNamingStrategy extends ComponentNamingStrat
                         // Validate cache.
                         Set<Resource> existingEntries = getMapSet(s2r, newName);
                         if (!existingEntries.isEmpty()) {
-                            System.out.println("WARNING: Somebody is screwing the model up with duplicate name: " + newName);
+                            LOGGER.warn("WARNING: Somebody is screwing the model up with duplicate name: " + newName);
                             // TODO: generate issue or message
                         }
 
@@ -164,7 +167,7 @@ public class CaseInsensitiveComponentNamingStrategy extends ComponentNamingStrat
                             if (existingEntries.contains(component))
                                 continue;
 
-                            System.out.println("WARNING: Somebody is screwing the model up with duplicate name: " + newName);
+                            LOGGER.warn("WARNING: Somebody is screwing the model up with duplicate name: " + newName);
                             // TODO: generate issue or message
                         }
 
@@ -300,8 +303,8 @@ public class CaseInsensitiveComponentNamingStrategy extends ComponentNamingStrat
                                 if (components.size() > 1) {
                                     // Found duplicate names in the model !!
                                     // TODO: generate issue!
-                                    System.err.println("WARNING: found multiple components with same name '" + componentName + "': " + components);
-                                    System.err.println("TODO: generate issue");
+                                    LOGGER.warn("WARNING: found multiple components with same name '" + componentName + "': " + components);
+                                    LOGGER.warn("TODO: generate issue");
                                 } else {
                                     String prevName = r2s.putIfAbsent(component, componentName);
                                     if (prevName == null)
@@ -486,7 +489,7 @@ public class CaseInsensitiveComponentNamingStrategy extends ComponentNamingStrat
     }
 
     private static void debug(Object obj, String string) {
-        System.out.println("[" + obj.getClass().getSimpleName() + "(" + System.identityHashCode(obj) + ")] " + string);
+        LOGGER.info("[" + obj.getClass().getSimpleName() + "(" + System.identityHashCode(obj) + ")] " + string);
     }
 
     private static <K,V> Set<V> addToMapSet(ConcurrentMap<K, Set<V>> map, K key, V value) {
index cd2c00b6dcf83f0dc47452fbb8428e65f6b2ce4f..a8a8a7319899fb3ef02cb576fa291ef22ed28eea 100644 (file)
@@ -46,6 +46,8 @@ import org.simantics.project.IProject;
 import org.simantics.structural.stubs.StructuralResource2;
 import org.simantics.utils.datastructures.Pair;
 import org.simantics.utils.ui.ErrorLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * A first-hand component naming strategy implementation for structural models.
@@ -61,6 +63,7 @@ import org.simantics.utils.ui.ErrorLogger;
  */
 public class CaseInsensitiveComponentNamingStrategy2 extends ComponentNamingStrategyBase implements ChangeListener {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(CaseInsensitiveComponentNamingStrategy2.class);
     private static final boolean            DEBUG_ALL                                     = false;
     private static final boolean            DEBUG_GRAPH_UPDATES                           = false | DEBUG_ALL;
     private static final boolean            DEBUG_CACHE_INITIALIZATION                    = false | DEBUG_ALL;
@@ -291,8 +294,8 @@ public class CaseInsensitiveComponentNamingStrategy2 extends ComponentNamingStra
                                 if (components.size() > 1) {
                                     // Found duplicate names in the model !!
                                     // TODO: generate issue!
-                                    System.err.println("WARNING: found multiple components with same name '" + componentName + "': " + components);
-                                    System.err.println("TODO: generate issue");
+                                    LOGGER.warn("WARNING: found multiple components with same name '" + componentName + "': " + components);
+                                    LOGGER.warn("TODO: generate issue");
                                 } else {
                                     String prevName = r2s.putIfAbsent(component, componentName);
                                     if (prevName == null)
index cf6690c311f0bdda988e695dc848d38cafd56390..0afdb03b7222c1f0d5f95fb8cc3c51c0d082bdb1 100644 (file)
@@ -44,9 +44,13 @@ import org.simantics.scl.runtime.tuple.Tuple3;
 import org.simantics.selectionview.SelectionViewResources;
 import org.simantics.structural.stubs.StructuralResource2;
 import org.simantics.structural2.utils.StructuralUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class ComponentTypeCommands {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(ComponentTypeCommands.class);
+
     public static void applyCode(WriteGraph g, Resource componentType, String code) throws DatabaseException {
         StructuralResource2 STR = StructuralResource2.getInstance(g);
         g.claimLiteral(componentType, STR.ProceduralComponentType_code, code, Bindings.STRING);
@@ -248,7 +252,7 @@ public class ComponentTypeCommands {
 
         Resource object = getAssertedObject(g, type, relation);
         if(object == null) {
-            System.err.println("Didn't find assertion for " + NameUtils.getSafeName(g, relation) + 
+            LOGGER.warn("Didn't find assertion for " + NameUtils.getSafeName(g, relation) + 
                     " in " + NameUtils.getSafeName(g, type) + ".");
             return;
         }
@@ -262,7 +266,7 @@ public class ComponentTypeCommands {
 
        Resource object = getAssertedObject(g, type, relation);
         if(object == null) {
-            System.err.println("Didn't find assertion for " + NameUtils.getSafeName(g, relation) + 
+            LOGGER.warn("Didn't find assertion for " + NameUtils.getSafeName(g, relation) + 
                     " in " + NameUtils.getSafeName(g, type) + ".");
             return;
         }
@@ -325,7 +329,7 @@ public class ComponentTypeCommands {
     public static void setUnit(WriteGraph graph, Resource type, Resource relation, String unit) throws DatabaseException {
         Resource object = getAssertedObject(graph, type, relation);
         if (object == null) {
-            System.err.println("Didn't find assertion for " + NameUtils.getSafeName(graph, relation) + 
+            LOGGER.warn("Didn't find assertion for " + NameUtils.getSafeName(graph, relation) + 
                     " in " + NameUtils.getSafeName(graph, type) + ".");
             return;
         }
@@ -360,7 +364,7 @@ public class ComponentTypeCommands {
     public static void setRange(WriteGraph graph, Resource type, Resource relation, String newRange) throws DatabaseException {
         Resource object = getAssertedObject(graph, type, relation);
         if (object == null) {
-            System.err.println("Didn't find assertion for " + NameUtils.getSafeName(graph, relation) + 
+            LOGGER.warn("Didn't find assertion for " + NameUtils.getSafeName(graph, relation) + 
                     " in " + NameUtils.getSafeName(graph, type) + ".");
             return;
         }
@@ -386,7 +390,7 @@ public class ComponentTypeCommands {
 
         Datatype newDatatype = TypeConversion.convertSCLTypeToDatatype(newSCLType);
         if(newDatatype == null) {
-            System.err.println("Couldn't convert default value to <" + newSCLType + ">.");
+            LOGGER.warn("Couldn't convert default value to <" + newSCLType + ">.");
             return null;
         }
         Binding newBinding = Bindings.getBinding(newDatatype);
@@ -415,7 +419,7 @@ public class ComponentTypeCommands {
             Resource type, Resource relation, String newSCLType) throws DatabaseException {
         Resource object = getAssertedObject(g, type, relation);
         if(object == null) {
-            System.err.println("Didn't find assertion for " + NameUtils.getSafeName(g, relation) + 
+            LOGGER.warn("Didn't find assertion for " + NameUtils.getSafeName(g, relation) + 
                     " in " + NameUtils.getSafeName(g, type) + ".");
             return;
         }
index d37947c4e2e11a5587e50e0e87b3b2a509937be5..7655f9ca5af13e08637c1357f78ca88368d2212d 100644 (file)
@@ -218,7 +218,7 @@ public class PlatformUtil {
                                LOGGER.error("Extraction to " + fileName + " failed from url " + url, e);
                        }
                } else {
-                       System.err.println("Unsupported URL protocol '" + url + "' for FastLZ native library file '" + fileName);
+                       LOGGER.error("Unsupported URL protocol '" + url + "' for FastLZ native library file '" + fileName);
                }       
                return null;
        }
index 93b3de91c70ef6b078ea0c5d8628d090497ab7db..a1207fbb5368666a2e140d0f8ae54c6e597727b0 100644 (file)
@@ -7,5 +7,6 @@ Bundle-Vendor: Semantum Oy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Require-Bundle: org.simantics;bundle-version="1.0.0",
  org.simantics.scenegraph;bundle-version="1.1.1";visibility:=reexport,
- org.simantics.scenegraph.ontology;bundle-version="1.0.0"
+ org.simantics.scenegraph.ontology;bundle-version="1.0.0",
+ org.slf4j.api
 Export-Package: org.simantics.scenegraph.loader
index e40773002ebfb68fb5bab610b5896c1e0f699001..b4b68a002ff4f360b0f30a1f9b7acbe366813aba 100644 (file)
@@ -42,9 +42,12 @@ import org.simantics.utils.DataContainer;
 import org.simantics.utils.datastructures.Pair;
 import org.simantics.utils.threads.IThreadWorkQueue;
 import org.simantics.utils.threads.ThreadUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class ScenegraphLoaderUtils {
-       
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(ScenegraphLoaderUtils.class);
        static Map<Pair<Variable, String>, Collection<Procedure<Object>>> externalMap = new HashMap<Pair<Variable, String>, Collection<Procedure<Object>>>(); 
        static Map<Pair<Variable, String>, Object> externalValueMap = new HashMap<Pair<Variable, String>, Object>(); 
 
@@ -506,10 +509,9 @@ public class ScenegraphLoaderUtils {
                try {
                        return node.getClass().getField(propertyName);
                } catch (SecurityException e) {
-                       e.printStackTrace();
+                       LOGGER.error("node: " + node, e);
                } catch (NoSuchFieldException e) {
-                       System.err.println("node:" + node);
-                       e.printStackTrace();
+                       LOGGER.error("node: " + node, e);
                }
                return null;
        }
index 3b402a86a3ee3f90e11f2bd606c0598dc9f5da11..150726681d476302270ca115f929c58fd2b5baaf 100644 (file)
 package com.infomatiq.jsi;
 
 import gnu.trove.TIntArrayList;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import gnu.trove.TFloatArrayList;
 
 /**
@@ -69,6 +73,7 @@ import gnu.trove.TFloatArrayList;
  * @version 1.0b8
  */
 public class PriorityQueue {
+  private static final Logger LOGGER = LoggerFactory.getLogger(PriorityQueue.class);
   public static final boolean SORT_ORDER_ASCENDING = true;
   public static final boolean SORT_ORDER_DESCENDING = false;
 
@@ -238,7 +243,7 @@ public class PriorityQueue {
       if (leftIndex <= lastIndex) {
         float leftPriority = priorities.get(leftIndex);
         if (sortsEarlierThan(leftPriority, currentPriority)) {
-          System.err.println("Internal error in PriorityQueue");
+          LOGGER.error("Internal error in PriorityQueue");
         }
       }
 
@@ -246,7 +251,7 @@ public class PriorityQueue {
       if (rightIndex <= lastIndex) {
         float rightPriority = priorities.get(rightIndex);
         if (sortsEarlierThan(rightPriority, currentPriority)) {
-          System.err.println("Internal error in PriorityQueue");
+          LOGGER.error("Internal error in PriorityQueue");
         }
       }
     }
index 6fd25e6f8359cbf81dfe7922448d837915618a18..fe3fe5e9de6a87834e8bdf114290e8a34b873dc0 100644 (file)
@@ -56,6 +56,8 @@ import org.simantics.scenegraph.utils.VRamBufferedImage;
 import org.simantics.scl.runtime.function.Function1;
 import org.simantics.scl.runtime.function.Function2;
 import org.simantics.utils.threads.AWTThread;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
@@ -77,6 +79,7 @@ public class SVGNode extends G2DNode implements InitValueSupport, LoaderNode {
 
        private static final long serialVersionUID = 8508750881358776559L;
 
+       private static final Logger LOGGER = LoggerFactory.getLogger(SVGNode.class);
     protected String          data             = null;
     protected String          defaultData      = null;
     protected Point           targetSize       = null;
@@ -324,7 +327,7 @@ public class SVGNode extends G2DNode implements InitValueSupport, LoaderNode {
                         e.setAttribute(ass.attributeNameOrId, ass.value);
                     }
                 } else {
-                    System.err.println("Element with id='" + ass.elementId + " was not found.");
+                    LOGGER.warn("Element with id='" + ass.elementId + " was not found.");
                 }
             }
 
@@ -473,7 +476,7 @@ public class SVGNode extends G2DNode implements InitValueSupport, LoaderNode {
         if (!data.equals(documentCache) || diagramCache == null) {
             dataHash = parseSVG();
             if (diagramCache == null) {
-                System.err.println("UNABLE TO PARSE SVG:\n" + data);
+                LOGGER.warn("UNABLE TO PARSE SVG:\n" + data);
                 return;
             }
         }
index b9ce6c012546c1f577dfb4a2465dd64b7a45197d..ce353b10875bdce0854d37646d9bda95541a36d7 100644 (file)
@@ -21,12 +21,15 @@ import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.simantics.scenegraph.g2d.G2DNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * @author Antti Villberg
  */
 public abstract class GraphPropertyNode extends G2DNode {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(GraphPropertyNode.class);
     private static final long serialVersionUID = 245761992671850588L;
 
     private static Map<Class<? extends GraphPropertyNode>, Map<String, Field>> fieldCache       = new ConcurrentHashMap<Class<? extends GraphPropertyNode>, Map<String, Field>>();
@@ -61,7 +64,7 @@ public abstract class GraphPropertyNode extends G2DNode {
     public void setProperty(String field, Object value) {
         Field f = fields.get(field);
         if (f == null) {
-            System.err.println("GraphPropertyNode tried to set undefined property '" + field + "'");
+            LOGGER.warn("GraphPropertyNode tried to set undefined property '" + field + "'");
             return;
         }
         try {
index 26717bc930696245df9b28ef8f6a5ce1f20e5e52..54323097badd9d77463d3dfe5497013e83ac93a9 100644 (file)
@@ -21,6 +21,9 @@ import java.awt.geom.Rectangle2D;
 import java.awt.image.VolatileImage;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import com.kitfox.svg.SVGDiagram;
 
 /**
@@ -33,6 +36,7 @@ import com.kitfox.svg.SVGDiagram;
  */
 public class MipMapVRamBufferedImage extends MipMapBufferedImage {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(MipMapVRamBufferedImage.class);
     /**
      * @param original
      * @param imageBounds
@@ -131,7 +135,7 @@ public class MipMapVRamBufferedImage extends MipMapBufferedImage {
 
             // Couldn't get image? This is not supposed to happen but happened anyway.
             if (image == null) {
-                System.err.println("BUG: VolatileImageProvider.get returned null!");
+                LOGGER.error("BUG: VolatileImageProvider.get returned null!");
                 return null;
             }
 
index 9439369a5927a89b9cfb714f15a296ef1c0ed678..5dac6fd2a59b68bc380fddbdbdda71efc5fd74f5 100644 (file)
@@ -54,6 +54,8 @@ import org.simantics.scl.runtime.function.Function1;
 import org.simantics.scl.runtime.function.FunctionImpl1;
 import org.simantics.utils.datastructures.Pair;
 import org.simantics.utils.threads.IThreadWorkQueue;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Utilities for debugging/printing the contents of a scenegraph.
@@ -62,6 +64,7 @@ import org.simantics.utils.threads.IThreadWorkQueue;
  */
 public final class NodeUtil {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(NodeUtil.class);
     /**
      * @param <T>
      */
@@ -607,7 +610,7 @@ public final class NodeUtil {
             } else {
 
                 if(pc.length > 0) {
-                    System.err.println("Method " + setter.getName() + " expects " + pc[0].getCanonicalName() + " (got " + value.getClass().getCanonicalName() + ").");
+                    LOGGER.warn("Method " + setter.getName() + " expects " + pc[0].getCanonicalName() + " (got " + value.getClass().getCanonicalName() + ").");
                 }
 
             }
@@ -936,7 +939,7 @@ public final class NodeUtil {
             // Find node transform..
             AffineTransform transform = getGlobalToLocalTransform(node, null);
             if (transform == null) {
-                System.err.println("WARNING: Non-invertible transform for node: " + node);
+                LOGGER.warn("WARNING: Non-invertible transform for node: " + node);
                 return event;
             }
             MouseEvent me = (MouseEvent)event;
@@ -975,7 +978,7 @@ public final class NodeUtil {
 
                     if(DEBUG_BOUNDS) {
                         for(int i=0;i<indent;i++) System.err.print(" ");
-                        System.err.println("+getLocalBoundsImpl " + next  + " => " + bl);
+                        LOGGER.warn("+getLocalBoundsImpl " + next  + " => " + bl);
                     }
 
                     if(bl != null) {
@@ -989,7 +992,7 @@ public final class NodeUtil {
 
                 if(DEBUG_BOUNDS) {
                     for(int i=0;i<indent;i++) System.err.print(" ");
-                    System.err.println("=getLocalBoundsImpl " + node  + " => " + bounds);
+                    LOGGER.warn("=getLocalBoundsImpl " + node  + " => " + bounds);
                 }
 
                 return bounds;
@@ -998,7 +1001,7 @@ public final class NodeUtil {
                 if(result != null) {
                     if(DEBUG_BOUNDS) {
                         for(int i=0;i<indent;i++) System.err.print(" ");
-                        System.err.println("=getLocalBoundsImpl " + node  + " => " + result);
+                        LOGGER.warn("=getLocalBoundsImpl " + node  + " => " + result);
                     }
                     return result;
                 }
index b136c78ef718b24e5dc433bf1824e839b25a8821..feaa6ed6ec165dccc1ad82a570df8fa3b7b22998 100644 (file)
@@ -9,4 +9,5 @@ Require-Bundle: org.simantics.db;bundle-version="1.1.0",
  org.simantics.scl.osgi;bundle-version="1.0.4",
  org.simantics.scl.compiler;bundle-version="0.4.0",
  org.simantics.db.common;bundle-version="1.1.0",
- org.simantics;bundle-version="1.0.0"
+ org.simantics;bundle-version="1.0.0",
+ org.slf4j.api
index 6f24e7d71b54d8323f79341741c218e4aafd8f37..70d2ad6a24f05e93bd8d1595f43421e9badde771 100644 (file)
@@ -8,8 +8,11 @@ import org.simantics.scl.compiler.top.SCLExpressionCompilationException;
 import org.simantics.scl.compiler.types.Type;
 import org.simantics.scl.runtime.function.Function;
 import org.simantics.scl.runtime.function.Function2;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class CommandSerializerFactory {
+    private static final Logger LOGGER = LoggerFactory.getLogger(CommandSerializerFactory.class);
     @SuppressWarnings("unchecked")
     public static CommandSerializer create(String name, Type[] parameterTypes) {
         Function2<Resource,Object,String>[] stringConverters = new Function[parameterTypes.length];
@@ -17,12 +20,12 @@ public class CommandSerializerFactory {
             try {
                 stringConverters[i] = StringConverterFactory.stringConverterFor(parameterTypes[i]);
             } catch(SCLExpressionCompilationException e) {
-                System.err.println("Failed to create a string converter for type " + parameterTypes[i] + ".");
-                System.err.println(CompilationErrorFormatter.toString(e.getErrors()));
+                LOGGER.error("Failed to create a string converter for type " + parameterTypes[i] + ".");
+                LOGGER.error(CompilationErrorFormatter.toString(e.getErrors()), e);
                 return new ErrorSerializer(name);
             } catch (ImportFailureException e) {
-                System.err.println("Failed to create a string converter for type " + parameterTypes[i] + ".");
-                System.err.println("Didn't find Simantics/GShow/gshow.");
+                LOGGER.error("Failed to create a string converter for type " + parameterTypes[i] + ".");
+                LOGGER.error("Didn't find Simantics/GShow/gshow.", e);
                 return new ErrorSerializer(name);
             }
         }
index 77048b2fe72453d958ca97c4b8dbb1ed2f0bdcc8..1c7c479d4bcedf24a2f40facc5bd28bf91358a39 100644 (file)
@@ -2,8 +2,11 @@ package org.simantics.scl.commands.internal.serialization;
 
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class ErrorSerializer implements CommandSerializer {
+    private static final Logger LOGGER = LoggerFactory.getLogger(ErrorSerializer.class);
     String name;
     
     public ErrorSerializer(String name) {
@@ -12,6 +15,6 @@ public class ErrorSerializer implements CommandSerializer {
 
     @Override
     public void serialize(WriteGraph graph, Resource context, Object[] parameters) {
-        System.err.println("Failed to serialize command " + name + ".");
+        LOGGER.error("Failed to serialize command " + name + ".");
     }
 }
index 85a613c437ba0a46263d8ef74d762a75ce29c1d3..954e8d0a3546ca07d2eb09b4ac284cd4e10726a4 100644 (file)
@@ -14,8 +14,11 @@ import org.simantics.scl.compiler.top.SCLCompilerConfiguration;
 import org.simantics.scl.compiler.types.TVar;
 import org.simantics.scl.compiler.types.Type;
 import org.simantics.scl.compiler.types.Types;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public final class ValRef implements IVal {
+    private static final Logger LOGGER = LoggerFactory.getLogger(ValRef.class);
     public static final ValRef[] EMPTY_ARRAY = new ValRef[0];
 
     Val binding;
@@ -55,8 +58,8 @@ public final class ValRef implements IVal {
             try {
                 binding.occurrence = next;
             } catch(NullPointerException e) {
-                System.err.println("removeModiId = " + removeModiId);
-                System.err.println("current ModiId = " + SSASimplificationContext.modiId);
+                LOGGER.error("removeModiId = " + removeModiId);
+                LOGGER.error("current ModiId = " + SSASimplificationContext.modiId, e);
                 throw new InternalCompilerError("The ValRef has already been removed.");
             }
         else
index 923acdba26115c6cd18d2a95d3bc15267a9a5536..22c7c7429432404655b5b55dfbdda47b1afd7ab4 100644 (file)
@@ -12,6 +12,8 @@ import org.simantics.scl.compiler.types.TVar;
 import org.simantics.scl.compiler.types.Type;
 import org.simantics.scl.compiler.types.Types;
 import org.simantics.scl.compiler.types.util.TypeUnparsingContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import gnu.trove.map.hash.TObjectIntHashMap;
 import gnu.trove.procedure.TObjectIntProcedure;
@@ -19,6 +21,8 @@ import gnu.trove.set.hash.THashSet;
 
 public class SSAValidationContext {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(SSAValidationContext.class);
+
     public THashSet<BoundVar> validBoundVariables = new THashSet<BoundVar>();
     public THashSet<Cont> validContinuations = new THashSet<Cont>();
     public THashSet<TVar> validTypeVariables = new THashSet<TVar>();
@@ -28,9 +32,10 @@ public class SSAValidationContext {
     public void assertEquals(Object loc, Type a, Type b) {
         if(!Types.equals(a, b)) {
             TypeUnparsingContext tuc = new TypeUnparsingContext();
-            System.err.println(a.toString(tuc) + " != " + b.toString(tuc));
+            String message = a.toString(tuc) + " != " + b.toString(tuc);
+            LOGGER.error(message);
             setErrorMarker(loc);
-            throw new InternalCompilerError();
+            throw new InternalCompilerError(message);
         }
     }
     
@@ -46,9 +51,10 @@ public class SSAValidationContext {
     public void assertEqualsEffect(Object loc, Type a, Type b) {
         if(!Types.equalsEffect(a, b)) {
             TypeUnparsingContext tuc = new TypeUnparsingContext();
-            System.err.println(a.toString(tuc) + " != " + b.toString(tuc));
+            String message = a.toString(tuc) + " != " + b.toString(tuc);
+            LOGGER.error(message);
             setErrorMarker(loc);
-            throw new InternalCompilerError();
+            throw new InternalCompilerError(message);
         }
     }
     
@@ -105,8 +111,8 @@ public class SSAValidationContext {
                 
                 int realCount = val.occurrenceCount();
                 if(realCount != count) {
-                    System.out.println(val + ": " + realCount + " != " + count);
-                    invalidReferenceCounts = true;                    
+                    LOGGER.warn(val + ": " + realCount + " != " + count);
+                    invalidReferenceCounts = true;
                 }
                 return true;
             }
index 84d3e3a01d4f37fd02e6fc331ba979b40bf7aa99..cf5a7a862c45fa99a5cad9b5148a6ec586910585 100644 (file)
@@ -11,6 +11,8 @@ import org.simantics.scl.compiler.types.Type;
 import org.simantics.scl.compiler.types.Types;
 import org.simantics.scl.compiler.types.kinds.Kind;
 import org.simantics.scl.compiler.types.kinds.Kinds;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import gnu.trove.map.hash.TObjectIntHashMap;
 import gnu.trove.set.hash.TIntHashSet;
@@ -20,7 +22,8 @@ import gnu.trove.set.hash.TIntHashSet;
  * This class represents an abstract syntax tree node for a type variable.
  * The only property of a type variable is its name.
  */
-public class TVarAst extends TypeAst {    
+public class TVarAst extends TypeAst {
+    private static final Logger LOGGER = LoggerFactory.getLogger(TVarAst.class);
     public final String name;
     
     public TVarAst(String name) {
@@ -98,7 +101,7 @@ public class TVarAst extends TypeAst {
                     if(name.charAt(i) != ',') {
                         con = context.resolveTypeConstructor(name.substring(1, name.length()-1));
                         if(con == null) {
-                            System.err.println("Didn't find type constructor " + name + ".");
+                            LOGGER.warn("Didn't find type constructor " + name + ".");
                             return Types.metaVar(Kinds.STAR);
                         }
                         break block;
@@ -112,7 +115,7 @@ public class TVarAst extends TypeAst {
             else {                
                 con = context.resolveTypeConstructor(name);
                 if(con == null) {
-                    System.err.println("Didn't find type constructor " + name + ".");
+                    LOGGER.warn("Didn't find type constructor " + name + ".");
                     return Types.metaVar(Kinds.STAR);
                 }
             }
@@ -159,7 +162,7 @@ public class TVarAst extends TypeAst {
         else {
             Type con = context.resolveTypeConstructor(name);
             if(con == null) {
-                System.err.println("Didn't find effect constructor " + name + ".");
+                LOGGER.warn("Didn't find effect constructor " + name + ".");
                 return Types.metaVar(Kinds.EFFECT);
             }
             return con;
index bec138283039b19b42582922c70cf9aec23a717f..d9e65e28c39208b575234aae41e3a94000702912 100644 (file)
@@ -23,6 +23,8 @@ import org.simantics.scl.compiler.types.TPred;
 import org.simantics.scl.compiler.types.TVar;
 import org.simantics.scl.compiler.types.Types;
 import org.simantics.scl.compiler.types.util.TypeUnparsingContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import gnu.trove.map.hash.THashMap;
 import gnu.trove.procedure.TObjectProcedure;
@@ -30,6 +32,7 @@ import gnu.trove.set.hash.THashSet;
 
 public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandler {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(SCLDocumentationExtensionNodeHandler.class);
     final ModuleRepository moduleRepository;
     final String documentationName;
     
@@ -56,7 +59,7 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle
                 if(name.isEmpty())
                     continue;
                 if(!documentedValues.add(name))
-                    System.err.println("Value '" + name + "' has already been documented in " + documentationName + ".");
+                    LOGGER.warn("Value '" + name + "' has already been documented in " + documentationName + ".");
                 generateValueDocumentation(container, name);
             }
             return container;
@@ -69,7 +72,7 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle
                 if(name.isEmpty())
                     continue;
                 if(!documentedClasses.add(name))
-                    System.err.println("Class '" + name + "' has already been documented in " + documentationName + ".");
+                    LOGGER.warn("Class '" + name + "' has already been documented in " + documentationName + ".");
                 generateClassDocumentation(container, name);
             }
             return container;
@@ -82,7 +85,7 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle
                 if(name.isEmpty())
                     continue;
                 if(!documentedTypeConstructors.add(name))
-                    System.err.println("Type constructor '" + name + "' has already been documented in " + documentationName + ".");
+                    LOGGER.warn("Type constructor '" + name + "' has already been documented in " + documentationName + ".");
                 generateDataDocumentation(container, name);
             }
             return container;
@@ -122,7 +125,7 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle
         if(relatedModule == null) {
             relatedModule = moduleRepository.getModule(documentationName);
             if(!relatedModule.didSucceed())
-                System.err.println("Couldn't load the module " + documentationName);
+                LOGGER.warn("Couldn't load the module " + documentationName);
         }
         if(relatedModule.didSucceed())
             return relatedModule.getResult();
@@ -136,7 +139,7 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle
             fm = moduleRepository.getModule(moduleName);
             moduleCache.put(moduleName, fm);
             if(!fm.didSucceed())
-                System.err.println("Couldn't load the module " + moduleName);
+                LOGGER.warn("Couldn't load the module " + moduleName);
         }
         if(fm.didSucceed())
             return fm.getResult();
@@ -165,12 +168,12 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle
         if(value == null) {
             StringBuilder error = new StringBuilder();
             error.append("Didn't find the value '" + name + "'.");
-            System.err.println(error);
+            LOGGER.error(error.toString());
             container.addChild(new CodeBlockNode(error));
             return;
         }
         if(value.isPrivate())
-            System.err.println("Documentation " + documentationName + " refers to a private value " + name + ".");
+            LOGGER.warn("Documentation " + documentationName + " refers to a private value " + name + ".");
         
         StringBuilder signature = new StringBuilder();
         signature.append("<div id=\"")
@@ -194,7 +197,7 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle
             container.addChild(parser.parseDocument(value.documentation));
         }
         else
-            System.out.println(name);
+            LOGGER.info(name);
         container.addChild(new HtmlNode("</div></div>"));
     }
     
@@ -221,7 +224,7 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle
         if(typeClass == null) {
             StringBuilder error = new StringBuilder();
             error.append("Didn't find the type class '" + name + "'.");
-            System.err.println(error);
+            LOGGER.error(error.toString());
             container.addChild(new CodeBlockNode(error));
             return;
         }
@@ -255,11 +258,11 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle
             container.addChild(parser.parseDocument(typeClass.documentation));
         }
         else
-            System.out.println(name);
+            LOGGER.info(name);
         
         for(String methodName : typeClass.methodNames) {
             if(!documentedValues.add(methodName))
-                System.err.println("Method '" + methodName + "' has already been documented in " + documentationName + ".");
+                LOGGER.warn("Method '" + methodName + "' has already been documented in " + documentationName + ".");
             generateValueDocumentation(container, module, methodName, new TypeUnparsingContext(tuc));
         }
         container.addChild(new HtmlNode("</div></div>"));
@@ -311,12 +314,12 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle
             container.addChild(parser.parseDocument(typeDescriptor.getDocumentation()));
         }
         else
-            System.out.println(name);
+            LOGGER.info(name);
         
         if(typeDescriptor instanceof TypeConstructor) {
             for(Constructor constructor : ((TypeConstructor)typeDescriptor).constructors) {
                 if(!documentedValues.add(constructor.name.name))
-                    System.err.println("Method '" + constructor.name.name + "' has already been documented in " + documentationName + ".");
+                    LOGGER.warn("Method '" + constructor.name.name + "' has already been documented in " + documentationName + ".");
                 generateValueDocumentation(container, module, constructor.name.name, new TypeUnparsingContext(tuc));
             }
         }
index fdb01e58d37ce2f1cf37a49dee5fd82eee3531e2..c186946437e572e83e234ce0d4a74a87ee8a0869 100644 (file)
@@ -5,6 +5,8 @@ import java.util.Arrays;
 
 import org.simantics.scl.compiler.parser.generator.grammar.AnaGrammar;
 import org.simantics.scl.compiler.parser.generator.grammar.Prod;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import gnu.trove.list.array.TIntArrayList;
 import gnu.trove.list.array.TLongArrayList;
@@ -20,6 +22,7 @@ import gnu.trove.set.hash.TIntHashSet;
 import gnu.trove.set.hash.TLongHashSet;
 
 public class ParseTableBuilder {
+    private static final Logger LOGGER = LoggerFactory.getLogger(ParseTableBuilder.class);
     public final static int MAX_STACK_ID = 10;
     
     private static final int STATE_MASK = 0x0fff;
@@ -129,8 +132,8 @@ public class ParseTableBuilder {
                 //System.out.println(newState + " " + grammar.getName(a) + " " + stackOp);
                 
                 if(stackOverflow) {
-                    System.err.println("Stack overflow when following " + grammar.getName(a) + " at");
-                    System.err.println(itemSet.toString(grammar));
+                    LOGGER.error("Stack overflow when following " + grammar.getName(a) + " at");
+                    LOGGER.error(itemSet.toString(grammar));
                 }
                 else {
                     int state = getState(a, b);
@@ -337,13 +340,13 @@ public class ParseTableBuilder {
                                     trans.put(symbol, REDUCE_MASK | production | (stackPos << 13));
                             }
                             else {
-                                System.err.println("Shift/reduce conflict when encountering " + grammar.terminalNames[symbol] + " in context");
-                                System.err.println(itemSets.get(i).toString(grammar));
+                                LOGGER.error("Shift/reduce conflict when encountering " + grammar.terminalNames[symbol] + " in context");
+                                LOGGER.error(itemSets.get(i).toString(grammar));
                             }
                         }
                         else {
-                            System.err.println("Reduce/reduce conflict when encountering " + grammar.terminalNames[symbol] + " in context");
-                            System.err.println(itemSets.get(i).toString(grammar));
+                            LOGGER.error("Reduce/reduce conflict when encountering " + grammar.terminalNames[symbol] + " in context");
+                            LOGGER.error(itemSets.get(i).toString(grammar));
                         }
                     }
                     else
@@ -392,7 +395,7 @@ public class ParseTableBuilder {
         
         builder.createReduceActions();
         
-        System.out.println("States: " + builder.itemSets.size());
+        LOGGER.info("States: " + builder.itemSets.size());
         
         //builder.visualize();
         
@@ -478,34 +481,34 @@ public class ParseTableBuilder {
             }
         });
         for(int i=0;i<stateSets.length;++i) {
-            System.out.println("--- State " + i + " ---");
-            System.out.println(stateSets[i].toString(grammar));
+            LOGGER.info("--- State " + i + " ---");
+            LOGGER.info(stateSets[i].toString(grammar));
             final TIntIntHashMap stackOp = stackOps.get(i);
             transitions.get(i).forEachEntry(new TIntIntProcedure() {
                 @Override
                 public boolean execute(int a, int b) {
                     int sOp = stackOp.get(a);
-                    System.out.print(grammar.getName(a) + " -> ");
+                    LOGGER.info(grammar.getName(a) + " -> ");
                     if(sOp != 0) {
-                        System.out.print("[");
+                        LOGGER.info("[");
                         if((sOp & PUSH_MASK) != 0) {
                             sOp ^= PUSH_MASK;
-                            System.out.print("PUSH ");
+                            LOGGER.info("PUSH ");
                         }
                         if((sOp & POP_MASK) != 0) {
                             sOp ^= POP_MASK;
-                            System.out.print("POP ");
+                            LOGGER.info("POP ");
                         }
                         if(sOp != 0)
-                            System.out.print(sOp);
-                        System.out.print("] ");
+                            LOGGER.info(Integer.toString(sOp));
+                        LOGGER.info("] ");
                     }
                     if((b & REDUCE_MASK) != 0) {
                         b ^= REDUCE_MASK;
-                        System.out.println("reduce " + b); // grammar.prods.get(~b).toString(grammar));
+                        LOGGER.info("reduce " + b); // grammar.prods.get(~b).toString(grammar));
                     }
                     else {
-                        System.out.println("shift " + b);
+                        LOGGER.info("shift " + b);
                     }
                     return true;
                 }
index e80858c5595034d8f5deeb46cfa183e8bdeb769f..f7db0d9cd9bd904669554ad06e64b26c2aab58bb 100644 (file)
@@ -1,8 +1,11 @@
 package org.simantics.scl.compiler.parser.grammar;
 
 import org.simantics.scl.compiler.parser.regexp.Namer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class Grammar implements Namer {
+    private static final Logger LOGGER = LoggerFactory.getLogger(Grammar.class);
     public final Production[] productions;
     public final String[] terminalNames;
     public final String[] nonterminalNames;
@@ -41,6 +44,6 @@ public class Grammar implements Namer {
             ++prodCount[~prod.lhs];
         for(int i=0;i<nonterminalNames.length;++i)
             if(prodCount[i]==0)
-                System.err.println("Nonterminal " + nonterminalNames[i] + " does not have productions.");
+                LOGGER.error("Nonterminal " + nonterminalNames[i] + " does not have productions.");
     }
 }
index 0fb121881b07210decce66d7e45241d16e5c5951..51d44ee6fbd451e1def409ac6f06d4ea86e50167 100644 (file)
@@ -8,7 +8,8 @@ Require-Bundle: org.simantics.scl.compiler;bundle-version="0.1.0";visibility:=re
  org.simantics.scl.runtime;bundle-version="0.1.4",
  gnu.trove3;bundle-version="3.0.0",
  org.eclipse.core.runtime;bundle-version="3.6.0",
- org.junit;bundle-version="4.12.0";resolution:=optional
+ org.junit;bundle-version="4.12.0";resolution:=optional,
+ org.slf4j.api
 Export-Package: org.simantics.scl.reflection,
  org.simantics.scl.reflection.annotations,
  org.simantics.scl.reflection.functions
index 8bfea3dbea9fb3291b4716b408a5f0921375d590..4e1d01816381d3ca486bae5b558f07f9af5cb7b2 100644 (file)
@@ -6,9 +6,12 @@ import org.eclipse.core.runtime.Status;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class Activator implements BundleActivator {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(Activator.class);
     private BundleContext context;  
     
     private static Activator instance;
@@ -34,7 +37,7 @@ public class Activator implements BundleActivator {
     }
         
     public static void logError(String description, Exception e) {
-        System.err.println(description);
+        LOGGER.error(description);
         if(e != null)
             e.printStackTrace();
         Bundle bundle = getInstance().getContext().getBundle();
index 8870eb98ea16fd90a41179094a8269fb23fc803f..bf3d6c68fb468d40f9dcd748cac00eb79f277648 100644 (file)
@@ -6,6 +6,8 @@ import java.io.IOException;
 import org.simantics.scl.runtime.SCLContext;
 import org.simantics.scl.runtime.function.Function;
 import org.simantics.scl.runtime.tuple.Tuple0;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Static methods for calling the currently active {@link SCLReportingHandler}.
@@ -14,6 +16,8 @@ import org.simantics.scl.runtime.tuple.Tuple0;
  */
 public class SCLReporting {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(SCLReporting.class);
+
     public static void print(String text) {
         SCLReportingHandler handler = ((SCLReportingHandler)SCLContext.getCurrent().get(SCLReportingHandler.REPORTING_HANDLER));
         if(handler != null)
@@ -27,7 +31,7 @@ public class SCLReporting {
         if(handler != null)
             handler.printError(text);
         else
-            System.err.println(text);
+            LOGGER.error(text);
     }
     
     public static void didWork(double amount) {
index 91e71d6521836314fb2c05b6140f8419df597137..4ea5fe66365d62df533d090b9f911498761952b4 100644 (file)
@@ -58,7 +58,7 @@ public interface SCLReportingHandler {
 
         @Override
         public void printError(String error) {
-            System.err.println(error);
+            LOGGER.error(error);
         }
     };
     
@@ -70,7 +70,7 @@ public interface SCLReportingHandler {
 
         @Override
         public void printError(String error) {
-            System.err.println(error);
+            LOGGER.error(error);
         }
 
         @Override
index 556475c191ce96d51b02835196308c5c0415c266..deaefad4d36dd6d93adbaca2a221476415f46f41 100644 (file)
@@ -16,7 +16,8 @@ Require-Bundle: org.eclipse.ui.editors;bundle-version="3.6.0",
  org.junit;bundle-version="4.12.0";resolution:=optional,
  com.ibm.icu,
  org.slf4j.api,
- org.eclipse.search;bundle-version="3.11.100"
+ org.eclipse.search;bundle-version="3.11.100",
+ org.eclipse.ui.views
 Export-Package: org.simantics.scl.ui.console,
  org.simantics.scl.ui.editor,
  org.simantics.scl.ui.editor2,
index 885fe77ed9f47b665b135741c06c5a2580b88c83..85e8aad7adcacf5f1b893a666594eec1788e8c04 100644 (file)
             searchResultClass="org.simantics.scl.ui.search.SCLSearchResult">
       </viewPage>
    </extension>
-
 </plugin>
index a293eaee1008c97ddda906211c2be6a240e0d130..ab9e033d020cca6d2537c83a35020c976419a8a7 100644 (file)
@@ -43,6 +43,7 @@ import org.eclipse.swt.widgets.Sash;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.preferences.ScopedPreferenceStore;
 import org.simantics.scl.runtime.tuple.Tuple2;
+import org.slf4j.Logger;
 
 /**
  * A console with input and output area that can be embedded
@@ -519,8 +520,7 @@ public abstract class AbstractCommandConsole extends Composite {
                 range.start = 0;
                 range.length = 1;
                 input.setStyleRange(range);
-                System.err.println("The following error message didn't have a proper location:");
-                System.err.println(annotation.description);
+                getLogger().error("The following error message didn't have a proper location: {}", annotation.description, e);
             }
         }
     }
@@ -603,4 +603,5 @@ public abstract class AbstractCommandConsole extends Composite {
         }
     }
 
+    public abstract Logger getLogger();
 }
index 9207bef3946529c51e587907540faa91e146b453..7221158c1bacfbfa8d91e27791ab84a49c8ee388 100644 (file)
@@ -24,6 +24,8 @@ import org.simantics.scl.runtime.reporting.SCLReportingHandler;
 import org.simantics.scl.ui.Activator;
 import org.simantics.scl.ui.assist.SCLContentProposalProvider;
 import org.simantics.scl.ui.assist.StyledTextContentAdapter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import gnu.trove.set.hash.THashSet;
 
@@ -258,4 +260,10 @@ public class SCLConsole extends AbstractCommandConsole {
                     }
                 }.open();
     }
+
+    @Override
+    public Logger getLogger() {
+        return LoggerFactory.getLogger(getClass());
+    }
+
 }
diff --git a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/outline/SCLModuleOutlinePage.java b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/outline/SCLModuleOutlinePage.java
new file mode 100644 (file)
index 0000000..d333f23
--- /dev/null
@@ -0,0 +1,142 @@
+package org.simantics.scl.ui.outline;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.part.Page;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
+import org.simantics.scl.ui.editor2.SCLModuleEditor2;
+
+public class SCLModuleOutlinePage extends Page implements IContentOutlinePage {
+
+    private SCLOutlineViewer outlineViewer;
+    private SCLModuleEditor2 moduleEditor;
+    
+    public SCLModuleOutlinePage(SCLModuleEditor2 moduleEditor) {
+        this.moduleEditor = moduleEditor;
+    }
+
+    @Override
+    public void addSelectionChangedListener(ISelectionChangedListener listener) {
+        if (outlineViewer != null)
+            outlineViewer.addSelectionChangedListener(listener);
+    }
+
+    @Override
+    public ISelection getSelection() {
+        if (outlineViewer != null)
+            outlineViewer.getSelection();
+        return StructuredSelection.EMPTY;
+    }
+
+    @Override
+    public void removeSelectionChangedListener(ISelectionChangedListener listener) {
+        if (outlineViewer != null)
+            outlineViewer.removeSelectionChangedListener(listener);
+    }
+
+    @Override
+    public void setSelection(ISelection selection) {
+        if (outlineViewer != null)
+            outlineViewer.setSelection(selection);
+    }
+
+    @Override
+    public void createControl(Composite parent) {
+        Tree tree = new Tree(parent, SWT.MULTI);
+        outlineViewer = new SCLOutlineViewer(tree);
+        
+        SCLModuleOutlineProvider provider = new SCLModuleOutlineProvider();
+        outlineViewer.setContentProvider(provider);
+        outlineViewer.setLabelProvider(provider);
+        
+        outlineViewer.setInput(moduleEditor.getEditorInput());
+    }
+
+    @Override
+    public Control getControl() {
+        if (outlineViewer != null)
+            outlineViewer.getControl();
+        return null;
+    }
+
+    @Override
+    public void setFocus() {
+        if (outlineViewer != null)
+            outlineViewer.getControl().setFocus();
+    }
+
+    protected class SCLOutlineViewer extends TreeViewer {
+
+        public SCLOutlineViewer(Tree tree) {
+            super(tree);
+            setAutoExpandLevel(ALL_LEVELS);
+            setUseHashlookup(true);
+        }
+
+        
+    }
+    
+    protected class SCLModuleOutlineProvider implements ITreeContentProvider, ILabelProvider {
+
+        @Override
+        public Object[] getElements(Object inputElement) {
+            return null;
+        }
+
+        @Override
+        public Object[] getChildren(Object parentElement) {
+            return null;
+        }
+
+        @Override
+        public Object getParent(Object element) {
+            return null;
+        }
+
+        @Override
+        public boolean hasChildren(Object element) {
+            return false;
+        }
+
+        @Override
+        public void addListener(ILabelProviderListener listener) {
+            
+        }
+
+        @Override
+        public boolean isLabelProperty(Object element, String property) {
+            return false;
+        }
+
+        @Override
+        public void removeListener(ILabelProviderListener listener) {
+            
+        }
+
+        @Override
+        public Image getImage(Object element) {
+            return null;
+        }
+
+        @Override
+        public String getText(Object element) {
+            return null;
+        }
+        
+        @Override
+        public void dispose() {
+            ITreeContentProvider.super.dispose();
+        }
+
+    }
+}
index 78f5c68d19b6fbf0ea5ab2d609a0b76a0aeb4077..6428f9b83db4b9d60730ad9ca0a77d1653822d92 100644 (file)
@@ -3,6 +3,8 @@ package org.simantics.spreadsheet.graph;
 import org.simantics.spreadsheet.graph.synchronization.SheetLineComponent;
 import org.simantics.structural.synchronization.base.ReferenceResolverBase;
 import org.simantics.structural.synchronization.base.Solver;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class SpreadsheetReferenceResolver extends ReferenceResolverBase<SheetLineComponent> {
 
@@ -15,5 +17,9 @@ public class SpreadsheetReferenceResolver extends ReferenceResolverBase<SheetLin
                throw new IllegalStateException();
        }
 
+    @Override
+    public Logger getLogger() {
+        return LoggerFactory.getLogger(getClass());
+    }
 
 }
index c6e5b32e2b3a41de7508c7195e8660f3c860fd8b..716086b63b76635a654b787a1079a6d46242b735 100644 (file)
@@ -4,11 +4,18 @@ import org.simantics.db.ReadGraph;
 import org.simantics.spreadsheet.graph.SpreadsheetBook;
 import org.simantics.spreadsheet.graph.SpreadsheetReferenceResolver;
 import org.simantics.structural.synchronization.base.SynchronizationEventHandlerBase;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class SpreadsheetSynchronizationEventHandler extends SynchronizationEventHandlerBase<SheetLineComponent> {
 
        public SpreadsheetSynchronizationEventHandler(ReadGraph graph, SpreadsheetBook book) {
                super(book, new SpreadsheetReferenceResolver(book), book, book, book, book.getMapping());
        }
-       
+
+    @Override
+    public Logger getLogger() {
+        return LoggerFactory.getLogger(getClass());
+    }
+
 }
index e86311f32bd9c228469be243826a6305c37ada1a..eae8126726e00f5c0a69b187394a80a35f7cdb1c 100644 (file)
@@ -11,6 +11,7 @@ Require-Bundle: org.simantics.databoard;bundle-version="0.6.5",
  org.simantics;bundle-version="1.0.0",
  org.simantics.simulation;bundle-version="1.1.0",
  org.simantics.datatypes.ontology;bundle-version="1.1.0",
- org.simantics.structural.synchronization;bundle-version="1.0.0";visibility:=reexport
+ org.simantics.structural.synchronization;bundle-version="1.0.0";visibility:=reexport,
+ org.slf4j.api
 Export-Package: org.simantics.structural.synchronization,
  org.simantics.structural.synchronization.base
index ef781f3df4f5d2035a2eb616a1e7273e546ebac3..7fabc6747f1c6fe27676fb7483bcad942b928408 100644 (file)
@@ -8,6 +8,7 @@ import java.util.Collections;
 
 import org.simantics.databoard.util.URIStringUtils;
 import org.simantics.structural.synchronization.protocol.SynchronizationEventHandler;
+import org.slf4j.Logger;
 
 abstract public class ReferenceResolverBase<T extends ComponentBase<T>> {
        
@@ -92,7 +93,7 @@ abstract public class ReferenceResolverBase<T extends ComponentBase<T>> {
                     String message = "Couldn't resolve " + connectionPoint +
                             ", because child " + segment + " does not exist.";
                     if(eventHandler == null)
-                        System.err.println(message);
+                        getLogger().warn(message);
                     else
                         eventHandler.reportProblem(message);
                     return;
@@ -139,14 +140,15 @@ abstract public class ReferenceResolverBase<T extends ComponentBase<T>> {
                 }
             });
             Collections.sort(pending);
-            System.out.println("Still pending:");
+            getLogger().info("Still pending:");
             for(String p : pending)
-                System.out.println("    " + p);
+                getLogger().info("    " + p);
         }
     }
 
     public void resolvePendingSelfReferences() {
         // Can be customized in subclasses
     }
-
+    
+    public abstract Logger getLogger();
 }
index 94bfbf89626bc1e1230688233dddbb0d8155d2f9..82dd224b6ec2f413f933a60ef5910bcbd72f1382 100644 (file)
@@ -15,6 +15,7 @@ import org.simantics.structural.synchronization.protocol.Connection;
 import org.simantics.structural.synchronization.protocol.SerializedVariable;
 import org.simantics.structural.synchronization.protocol.SynchronizationEventHandler;
 import org.simantics.structural.synchronization.protocol.SynchronizationException;
+import org.slf4j.Logger;
 
 import gnu.trove.map.hash.THashMap;
 import gnu.trove.set.hash.THashSet;
@@ -401,12 +402,11 @@ public abstract class SynchronizationEventHandlerBase<T extends ComponentBase<T>
     }
 
     public void reportProblem(String description) {
-        System.err.println(description);
+        getLogger().error(description);
     }
     
     public void reportProblem(String description, Exception e) {
-        System.err.println(description);
-        e.printStackTrace();
+        getLogger().error(description, e);
     }
     
     public void addPostSynchronizationAction(Runnable action) {
@@ -421,4 +421,6 @@ public abstract class SynchronizationEventHandlerBase<T extends ComponentBase<T>
     public long getFromRevision() {
         return mapping.currentRevision;
     }
+    
+    public abstract Logger getLogger();
 }
index ad9b7fe5653a87bb590924c1880e4e4b66d9206c..787d2c567f26b782c19addd6936e65cfba95b15f 100644 (file)
@@ -9,4 +9,5 @@ Export-Package: org.simantics.structural.synchronization.base2,
  org.simantics.structural.synchronization.utils
 Require-Bundle: org.simantics.databoard;bundle-version="0.6.5",
  org.eclipse.core.runtime;bundle-version="3.7.0",
- gnu.trove3;bundle-version="3.0.3"
+ gnu.trove3;bundle-version="3.0.3",
+ org.slf4j.api
index f316cbfc7cb49aa837a27ec1cef03ed497607da2..974c632469b557a40663febcde1eba502bf41372 100644 (file)
@@ -7,9 +7,12 @@ import org.simantics.structural.synchronization.protocol.Connection;
 import org.simantics.structural.synchronization.protocol.SerializedVariable;
 import org.simantics.structural.synchronization.protocol.SynchronizationEventHandler;
 import org.simantics.structural.synchronization.protocol.SynchronizationException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class DiagnosticSynchronizationEventHandler implements SynchronizationEventHandler {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(DiagnosticSynchronizationEventHandler.class);
     int indentation;
 
     @Override
@@ -25,28 +28,35 @@ public class DiagnosticSynchronizationEventHandler implements SynchronizationEve
             Collection<SerializedVariable> properties,
             Collection<Connection> connections, Collection<ChildInfo> children)
                     throws SynchronizationException {
+        StringBuilder indent = new StringBuilder();
         for(int i=0;i<indentation;++i)
-            System.out.print("  ");
-        System.out.print(name);
+            indent.append("  ");
+        indent.append(name);
         if(typeId != null)
-            System.out.print(" :: " + typeId);
-        System.out.println();
+            indent.append(" :: " + typeId);
+        LOGGER.info(indent.toString());
         for(SerializedVariable var : properties) {
+            indent = new StringBuilder();
             for(int i=0;i<=indentation;++i)
-                System.out.print("  ");
-            System.out.println(SerializedVariable.print(var, indentation*2+2));
+                indent.append("  ");
+            indent.append(SerializedVariable.print(var, indentation*2+2));
+            LOGGER.info(indent.toString());
         }
         for(Connection connection : connections) {
+            indent = new StringBuilder();
             for(int i=0;i<=indentation;++i)
-                System.out.print("  ");
-            System.out.println(connection);
+                indent.append("  ");
+            indent.append(connection);
+            LOGGER.info(indent.toString());
         }
         if(!children.isEmpty()) {
+            indent = new StringBuilder();
             for(int i=0;i<=indentation;++i)
-                System.out.print("  ");
-            System.out.print("Children ");
+                indent.append("  ");
+            indent.append("Children ");
             if(children != null)
-                System.out.println(children);
+                indent.append(children);
+            LOGGER.info(indent.toString());
         }
         ++indentation;
     }
@@ -58,25 +68,24 @@ public class DiagnosticSynchronizationEventHandler implements SynchronizationEve
 
     @Override
     public void beginType(String id, Collection<SerializedVariable> properties) {
-        System.out.println("--- Type " + id + " --------------------------------");
+        LOGGER.info("--- Type " + id + " --------------------------------");
         for(SerializedVariable var : properties)
-            System.out.println(SerializedVariable.print(var, 2));
+            LOGGER.info(SerializedVariable.print(var, 2));
     }
 
     @Override
     public void endType() {
-        System.out.println("----------------------------------------------------");
+        LOGGER.info("----------------------------------------------------");
     }
 
     @Override
     public void reportProblem(String description) {
-        System.err.println(description);
+        LOGGER.error(description);
     }
 
     @Override
     public void reportProblem(String description, Exception e) {
-        System.err.println(description);
-        e.printStackTrace();
+        LOGGER.error(description, e);
     }
 
 }
index 0db9d7033df415da9800f5924bd2d836f343274c..a5b50f6f36bc5dc7f1368ff0acc80d9ea4a46e23 100644 (file)
@@ -37,9 +37,11 @@ import org.simantics.structural2.procedural.Interface;
 import org.simantics.structural2.procedural.Property;
 import org.simantics.structural2.procedural.Terminal;
 import org.simantics.utils.datastructures.Pair;
+import org.slf4j.LoggerFactory;
 
 public class StandardProceduralChildVariable extends AbstractChildVariable {
 
+    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(StandardProceduralChildVariable.class);
        /*
         * Extension points
         * 
@@ -84,7 +86,7 @@ public class StandardProceduralChildVariable extends AbstractChildVariable {
                                result.add(desc.getVariable(graph));
                        }
                 else
-                       System.err.println("no cp " + cp.first + " for " + component.getURI(graph));
+                       LOGGER.warn("no cp " + cp.first + " for " + component.getURI(graph));
             }
             return result;
             
@@ -102,7 +104,7 @@ public class StandardProceduralChildVariable extends AbstractChildVariable {
                                result.add(desc.getURI(graph));
                        }
                 else
-                       System.err.println("no cp " + cp.first + " for " + component.getURI(graph));
+                       LOGGER.warn("no cp " + cp.first + " for " + component.getURI(graph));
             }
             return result;
                        
@@ -118,7 +120,7 @@ public class StandardProceduralChildVariable extends AbstractChildVariable {
                if(cp2 != null)
                        result.addAll(ConnectionBrowser.flatten(graph, component, cp.second, relationType));
                 else
-                       System.err.println("no cp " + cp.first + " for " + component.getURI(graph));
+                       LOGGER.warn("no cp " + cp.first + " for " + component.getURI(graph));
             }
             return result;
                        
index 1daf9cc51020677f157d875219211ab98b25d926..fa1ce29bd97727be601a403241b6b09b65c75800 100644 (file)
@@ -10,7 +10,8 @@ Require-Bundle: org.eclipse.core.runtime,
  org.simantics.databoard;bundle-version="0.6.2",
  org.simantics.history;bundle-version="1.0.0",
  org.simantics.simulation;bundle-version="1.1.0";resolution:=optional,
- com.lowagie.text;bundle-version="2.1.5";resolution:=optional
+ com.lowagie.text;bundle-version="2.1.5";resolution:=optional,
+ org.slf4j.api
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Export-Package: org.simantics.trend,
index dcbd1c797a28ac138a0037792fbbff2a000d2130..c866d2cc290490d9f48804193de8926af128ed9e 100644 (file)
@@ -54,6 +54,7 @@ import org.simantics.trend.configuration.TrendItem;
 import org.simantics.trend.configuration.TrendItem.DrawMode;
 import org.simantics.trend.configuration.TrendItem.Renderer;
 import org.simantics.trend.util.KvikDeviationBuilder;
+import org.slf4j.LoggerFactory;
 
 /**
  * Data node for a TrendItem
@@ -63,7 +64,8 @@ import org.simantics.trend.util.KvikDeviationBuilder;
 public class ItemNode extends G2DNode implements TrendLayout {
 
        private static final long serialVersionUID = -4741446944761752871L;
-
+       private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(ItemNode.class);
+       
        public static final AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .61f);
 
        public TrendItem item;
@@ -329,7 +331,7 @@ public class ItemNode extends G2DNode implements TrendLayout {
                        s.accessor.get(i, s.sampleBinding, vb.getSample());
                        
                        if(!validSample(vb)) {
-                               System.err.println("-invalid value band: " + i + "/" + count + ":" + vb);
+                               LOGGER.warn("-invalid value band: " + i + "/" + count + ":" + vb);
                                continue;
                        }
                        // Non-continuation point
index 1805d0dab4b451f2a345715a63b4ff79138a850e..d987c344431ae39d53316f5dee9044c73eb9e748 100644 (file)
@@ -24,12 +24,15 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.util.SessionGarbageCollection;
 import org.simantics.db.service.LifecycleSupport;
 import org.simantics.utils.ui.ErrorLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * @author Tuukka Lehtonen
  */
 public class SessionGarbageCollectorJob extends Job {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(SessionGarbageCollectorJob.class);
     private static SessionGarbageCollectorJob instance;
 
     public synchronized static SessionGarbageCollectorJob getInstance() {
@@ -133,7 +136,7 @@ public class SessionGarbageCollectorJob extends Job {
         if (TRACE) {
             if (!enabled) {
                 long t = System.currentTimeMillis();
-                System.out.println("GC disabled, not running @ " + ((double) (t - start) * 1e-3) + " seconds");
+                LOGGER.info("GC disabled, not running @ " + ((double) (t - start) * 1e-3) + " seconds");
             }
         }
         return enabled;
@@ -175,7 +178,7 @@ public class SessionGarbageCollectorJob extends Job {
 
             long begin = System.currentTimeMillis();
             if (TRACE) {
-                System.out.println("running GC @ " + ((double) (begin - start) * 1e-3) + " seconds");
+                LOGGER.info("running GC @ " + ((double) (begin - start) * 1e-3) + " seconds");
             }
 
             boolean busy = SessionGarbageCollection.gc(monitor, session, true, errorCallback);
@@ -188,7 +191,7 @@ public class SessionGarbageCollectorJob extends Job {
 
             if (TRACE)
                if(busy)
-                       System.err.println("Session GC ended busy. New quiet time is " + quietTime);
+                       LOGGER.info("Session GC ended busy. New quiet time is " + quietTime);
             
             // This quiet time might have been adjusted in GC
             interval = quietTime;
@@ -201,7 +204,7 @@ public class SessionGarbageCollectorJob extends Job {
             if (TRACE) {
                 //long end = System.currentTimeMillis();
                 //System.out.println("Session.GC " + (intermediate - begin) + "ms, System.GC " + (end-intermediate) + "ms, total " + (end - begin) + "ms");
-                System.out.println("Session.GC " + (intermediate - begin) + "ms");
+                LOGGER.info("Session.GC " + (intermediate - begin) + "ms");
             }
 
             // Reschedule after a quiet period.
index 6a1b2c027165154ffdd23f6e031c52589fe14427..9cba52a3713a77faf198284cca2b614f689c576b 100644 (file)
@@ -17,12 +17,15 @@ import java.util.List;
 
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * @author Tuukka Lehtonen
  */
 public class WorkbenchShutdownServiceImpl implements WorkbenchShutdownService {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(WorkbenchShutdownServiceImpl.class);
     private static ServiceRegistration service = null;
 
     private final List<Runnable>       hooks   = new ArrayList<Runnable>();
@@ -72,8 +75,7 @@ public class WorkbenchShutdownServiceImpl implements WorkbenchShutdownService {
     }
 
     protected void handleException(Object source, Throwable t) {
-        System.err.println(getClass().getSimpleName() + ": workbench shutdown hook " + source + " caused unexpected exception:");
-        t.printStackTrace();
+        LOGGER.error(getClass().getSimpleName() + ": workbench shutdown hook " + source + " caused unexpected exception:", t);
     }
 
 }
index 44435fa6ed41421f640db3fa1312de4e0857c81d..d55b3da708bf8625cacd8d6471344e59c27e2ad0 100644 (file)
@@ -7,3 +7,4 @@ Export-Package: org.simantics.utils.threads,
  org.simantics.utils.threads.logger
 Bundle-Vendor: VTT Technical Research Centre of Finland
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Require-Bundle: org.slf4j.api
index e9a6fa4e3aaa63645e2889e4b0050e009d71545f..cd8d6027e4d7c54b56eaa56a3ef39b24ea4adcae 100644 (file)
@@ -38,6 +38,9 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.locks.Lock;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 /**
  * Utility for switching threads
  * 
@@ -46,6 +49,7 @@ import java.util.concurrent.locks.Lock;
  */
 public class ThreadUtils {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(ThreadUtils.class);
     public static final int CORES = Runtime.getRuntime().availableProcessors();
 
     /**
@@ -886,10 +890,10 @@ public class ThreadUtils {
             if (!pool.awaitTermination(timeoutMs, TimeUnit.MILLISECONDS)) {
                 List<Runnable> leftovers = pool.shutdownNow(); // Cancel currently executing tasks
                 if (!leftovers.isEmpty())
-                    System.err.println("Thread pool '" + pool.toString()  + "' contained " + leftovers.size() + " tasks at forced shutdown: " + leftovers);
+                    LOGGER.warn("Thread pool '" + pool.toString()  + "' contained " + leftovers.size() + " tasks at forced shutdown: " + leftovers);
                 // Wait a while for tasks to respond to being cancelled
                 if (!pool.awaitTermination(timeoutMs, TimeUnit.MILLISECONDS))
-                    System.err.println("Thread pool '" + pool.toString()  + "' did not terminate");
+                    LOGGER.warn("Thread pool '" + pool.toString()  + "' did not terminate");
             }
         } catch (InterruptedException ie) {
             // (Re-)Cancel if current thread also interrupted
index 9790dcd0696ff2f6aa14406fdc15110b76943f46..132a74a80f86e10659ed9d711e3f7baf35962cb2 100644 (file)
@@ -9,7 +9,8 @@ Require-Bundle: org.eclipse.core.runtime,
  org.simantics.utils,
  org.simantics.utils.datastructures,
  org.eclipse.ui;bundle-version="3.7.0",
- org.eclipse.core.expressions
+ org.eclipse.core.expressions,
+ org.slf4j.api
 Export-Package: org.simantics.utils.ui,
  org.simantics.utils.ui.action,
  org.simantics.utils.ui.awt,
index 864c6840209e0fe9d69ded1683f3d3ff49ea763f..0c3b9763a6f12cbf2c0cf262154224be402aaee5 100644 (file)
@@ -36,6 +36,8 @@ import org.eclipse.swt.events.MouseTrackListener;
 import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.RGB;
 import org.eclipse.swt.widgets.Composite;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * This is a TrackedTest SWT Text-widget 'decorator'.
@@ -64,6 +66,7 @@ import org.eclipse.swt.widgets.Composite;
  * @author Tuukka Lehtonen
  */
 public class TrackedStyledText {
+    private static final Logger LOGGER = LoggerFactory.getLogger(TrackedStyledText.class);
     private static final int      EDITING                 = 1 << 0;
     private static final int      MODIFIED_DURING_EDITING = 1 << 1;
 
@@ -366,7 +369,7 @@ public class TrackedStyledText {
     }
 
     private void applyEdit() {
-       System.err.println("apply edit");
+       LOGGER.info("apply edit");
         try {
             if (isTextValid() != null) {
                 text.setText(textBeforeEdit);
@@ -393,7 +396,7 @@ public class TrackedStyledText {
     }
 
     private void endEdit() {
-       System.err.println("endedit");
+       LOGGER.info("endedit");
         if (!isEditing()) {
             // Print some debug incase we end are in an invalid state
             //ExceptionUtils.logError(new Exception("BUG: endEdit called when not in editing state"));
@@ -411,7 +414,7 @@ public class TrackedStyledText {
         if (!isEditing()) {
             // Print some debug incase we end are in an invalid state
             //ExceptionUtils.logError(new Exception("BUG: revertEdit called when not in editing state"));
-            System.out.println("BUG: revertEdit called when not in editing state");
+            LOGGER.warn("BUG: revertEdit called when not in editing state");
         }
         text.setText(textBeforeEdit);
         text.setSelection(caretPositionBeforeEdit);
index afaec5c32a5291c80724e0cbcfee57a9622df564..84c13b4d82973f81706ae881fe2736821f5dff1e 100644 (file)
@@ -10,9 +10,12 @@ import org.simantics.databoard.adapter.AdaptException;
 import org.simantics.databoard.binding.Binding;
 import org.simantics.databoard.binding.error.BindingException;
 import org.simantics.databoard.binding.mutable.Variant;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class Development {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(Development.class);
        public static TreeMap<String,Integer> histogram = new TreeMap<String,Integer>();
 
        public static final boolean DEVELOPMENT = false;
@@ -37,7 +40,7 @@ public class Development {
                                @Override
                                public void handle(Object event) {
                                        if((Boolean) getProperty(PRINT, Bindings.BOOLEAN))
-                                               System.err.println(event.toString());
+                                               LOGGER.info(event.toString());
                                }
        
                        });
@@ -95,7 +98,11 @@ public class Development {
                String key = o.toString();
                Integer i = Development.histogram.get(key);
                if(i == null) i = 0;
-               Development.histogram.put(key, i+1);
+               int newValue = i+1;
+               if (newValue == 1000) {
+                   newValue = newValue;
+               }
+               Development.histogram.put(key, newValue);
        }
        
 }
index 710abbf56c92c3e98a40ff18a4973e7af8ec9cd6..5cfd3d9877fa59882182a601bebf1da9fc2513e3 100644 (file)
@@ -12,4 +12,5 @@ Require-Bundle: org.junit;bundle-version="4.12.0",
  ch.qos.logback.classic;bundle-version="1.1.7",
  ch.qos.logback.core;bundle-version="1.1.7",
  org.apache.commons.collections;bundle-version="3.2.2",
- org.eclipse.equinox.ds;bundle-version="1.4.300"
+ org.eclipse.equinox.ds;bundle-version="1.4.300",
+ org.slf4j.api
index 76cd51e900923c88917cd61d2ac1dde235f72646..29c1906237835d06a4308dda3f5b7981bee7d307 100644 (file)
@@ -13,8 +13,11 @@ import org.simantics.scl.compiler.top.ExpressionEvaluator;
 import org.simantics.scl.compiler.top.SCLExpressionCompilationException;
 import org.simantics.scl.compiler.types.Type;
 import org.simantics.scl.compiler.types.Types;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class MemoryLeakExperiment {
+    private static final Logger LOGGER = LoggerFactory.getLogger(MemoryLeakExperiment.class);
     ModuleRepository moduleRepository;
 
     EnvironmentSpecification environmentSpecification;
@@ -39,7 +42,7 @@ public class MemoryLeakExperiment {
                     getClass().getClassLoader());
         } catch(ImportFailureException e) {
             for(ImportFailure failure : e.failures)
-                System.err.println("Failed to import " + failure.moduleName);
+                LOGGER.warn("Failed to import " + failure.moduleName);
             throw e;
         }
 
@@ -52,7 +55,7 @@ public class MemoryLeakExperiment {
             if(expectedValue != null)
                 Assert.assertEquals(expectedValue, result);
         } catch(SCLExpressionCompilationException e) {
-            System.out.println(CompilationErrorFormatter.toString(expressionText, e.getErrors()));
+            LOGGER.error(CompilationErrorFormatter.toString(expressionText, e.getErrors()));
             throw e;
         }
     }
@@ -67,7 +70,7 @@ public class MemoryLeakExperiment {
                 System.gc();
                 Thread.sleep(100L);
                 double used = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory());
-                System.out.println(i + " " + used*1e-6 + " Mb, " + (used / i) + " b / expression");
+                LOGGER.info(i + " " + used*1e-6 + " Mb, " + (used / i) + " b / expression");
             }
         }
     }
index 784a80b4c6072383d659786d57bd9e0eb48fd1ec..ffeaa6b6ff8fa7cc42e011f5c19c863aaa9db54b 100644 (file)
@@ -5,14 +5,16 @@ import org.junit.Before;
 import org.junit.Test;
 import org.simantics.scl.compiler.commands.CommandSession;
 import org.simantics.scl.compiler.errors.CompilationError;
-import org.simantics.scl.compiler.errors.CompilationErrorFormatter;
 import org.simantics.scl.compiler.module.repository.ModuleRepository;
 import org.simantics.scl.runtime.reporting.AbstractSCLReportingHandler;
 import org.simantics.scl.runtime.reporting.SCLReportingHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 public class TestCommandSession {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(TestCommandSession.class);
     ModuleRepository moduleRepository;
 
     @Before
@@ -30,11 +32,11 @@ public class TestCommandSession {
     private static final SCLReportingHandler TEST_HANDLER = new AbstractSCLReportingHandler() {
         @Override
         public void print(String text) {
-            System.out.println(text);
+            LOGGER.info(text);
         }
         
         public void printError(String error) {
-            System.err.println(error);
+            LOGGER.error(error);
             throw new SCLErrorMessageException(error);
         }
     };
index 2e887ca1a420b04a0ed1dda7cc702f64bdd9b728..b78d485287e5bcfee07a47dc87a8d702135fb0f4 100644 (file)
@@ -17,17 +17,18 @@ import org.simantics.scl.compiler.module.repository.ImportFailure;
 import org.simantics.scl.compiler.module.repository.ImportFailureException;
 import org.simantics.scl.compiler.module.repository.ModuleRepository;
 import org.simantics.scl.compiler.runtime.RuntimeEnvironment;
-import org.simantics.scl.compiler.source.repository.CompositeModuleSourceRepository;
-import org.simantics.scl.compiler.source.repository.SourceRepositories;
 import org.simantics.scl.compiler.top.ExpressionEvaluator;
 import org.simantics.scl.compiler.top.SCLExpressionCompilationException;
 import org.simantics.scl.compiler.types.Type;
 import org.simantics.scl.compiler.types.Types;
 import org.simantics.scl.runtime.function.Function;
 import org.simantics.scl.runtime.tuple.Tuple0;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class TestExpressionEvaluator {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(TestExpressionEvaluator.class);
     public static final boolean TIMING = false;
     public static final int COUNT = 10000;
 
@@ -49,7 +50,7 @@ public class TestExpressionEvaluator {
                     getClass().getClassLoader());
         } catch(ImportFailureException e) {
             for(ImportFailure failure : e.failures)
-                System.err.println("Failed to import " + failure.moduleName);
+                LOGGER.warn("Failed to import " + failure.moduleName);
             throw e;
         }
     }
@@ -65,7 +66,7 @@ public class TestExpressionEvaluator {
             if(expectedValue != null)
                 Assert.assertEquals(expectedValue, result);
         } catch(SCLExpressionCompilationException e) {
-            System.out.println(CompilationErrorFormatter.toString(expressionText, e.getErrors()));
+            LOGGER.error(CompilationErrorFormatter.toString(expressionText, e.getErrors()));
             throw e;
         }
     }
@@ -74,12 +75,12 @@ public class TestExpressionEvaluator {
             Object expectedValue,
             Type expectedType) throws Exception {
         if(TIMING) {
-            System.out.println(expressionText);
+            LOGGER.info(expressionText);
             long beginTime = System.nanoTime();
             for(int i=0;i<COUNT;++i)
                 testExpression0(expressionText, expectedValue, expectedType);
             long endTime = System.nanoTime();
-            System.out.println( "    " + (endTime-beginTime)*1e-6/COUNT + " ms");
+            LOGGER.info( "    " + (endTime-beginTime)*1e-6/COUNT + " ms");
         }
         else
             testExpression0(expressionText, expectedValue, expectedType);
@@ -150,7 +151,7 @@ public class TestExpressionEvaluator {
                     Double.valueOf(15.0),
                     ((Function)result).apply(7.0, 8.0));
         } catch(SCLExpressionCompilationException e) {
-            System.out.println(CompilationErrorFormatter.toString(expressionText, e.getErrors()));
+            LOGGER.error(CompilationErrorFormatter.toString(expressionText, e.getErrors()));
             throw e;
         }
     }