From: jsimomaa Date: Wed, 17 Jan 2018 09:22:13 +0000 (+0200) Subject: Replace System.err and System.out with SLF4J Logging X-Git-Tag: v1.43.0~136^2~623 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=1dfeb7d5;p=simantics%2Fplatform.git Replace System.err and System.out with SLF4J Logging refs #7719 Change-Id: Iae42f94b542b17bc2e1aa839f506a6e1a46928ae --- diff --git a/bundles/org.simantics.acorn/src/org/simantics/acorn/ClusterManager.java b/bundles/org.simantics.acorn/src/org/simantics/acorn/ClusterManager.java index 9725ffe8d..85daddd22 100644 --- a/bundles/org.simantics.acorn/src/org/simantics/acorn/ClusterManager.java +++ b/bundles/org.simantics.acorn/src/org/simantics/acorn/ClusterManager.java @@ -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 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]); diff --git a/bundles/org.simantics.acorn/src/org/simantics/acorn/FileIO.java b/bundles/org.simantics.acorn/src/org/simantics/acorn/FileIO.java index c5480d86e..8f3009afa 100644 --- a/bundles/org.simantics.acorn/src/org/simantics/acorn/FileIO.java +++ b/bundles/org.simantics.acorn/src/org/simantics/acorn/FileIO.java @@ -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 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."); + } } } diff --git a/bundles/org.simantics.acorn/src/org/simantics/acorn/GraphClientImpl2.java b/bundles/org.simantics.acorn/src/org/simantics/acorn/GraphClientImpl2.java index 07fe18e61..09929f775 100644 --- a/bundles/org.simantics.acorn/src/org/simantics/acorn/GraphClientImpl2.java +++ b/bundles/org.simantics.acorn/src/org/simantics/acorn/GraphClientImpl2.java @@ -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 { + private static final Logger LOGGER = LoggerFactory.getLogger(ChangeSetInfo.class); private byte[] metadataBytes; private ArrayList clusterChangeSetIds; @@ -110,4 +113,8 @@ public class ChangeSetInfo extends LRUObject { return false; } + @Override + public Logger getLogger() { + return LOGGER; + } } \ No newline at end of file diff --git a/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/ClusterInfo.java b/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/ClusterInfo.java index f20b38456..54689394d 100644 --- a/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/ClusterInfo.java +++ b/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/ClusterInfo.java @@ -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 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 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 implements P protected boolean overwrite() { return true; } - + + @Override + public Logger getLogger() { + return LOGGER; + } } \ No newline at end of file diff --git a/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/ClusterLRU.java b/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/ClusterLRU.java index ecc016723..e94abf7f2 100644 --- a/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/ClusterLRU.java +++ b/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/ClusterLRU.java @@ -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 { + private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(ClusterLRU.class); + final private BijectionMap clusterMapping = new BijectionMap(); public ClusterLRU(ClusterManager manager, String identifier, Path writeDir) { @@ -284,7 +287,7 @@ public class ClusterLRU extends LRU { 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 { 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."); + } } } diff --git a/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/ClusterStreamChunk.java b/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/ClusterStreamChunk.java index 57d6f6a04..12d4d55b8 100644 --- a/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/ClusterStreamChunk.java +++ b/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/ClusterStreamChunk.java @@ -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 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 im protected boolean overwrite() { return false; } - + + @Override + public Logger getLogger() { + return LOGGER; + } } \ No newline at end of file diff --git a/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/FileInfo.java b/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/FileInfo.java index 116464727..0e1367f99 100644 --- a/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/FileInfo.java +++ b/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/FileInfo.java @@ -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 { + private static final Logger LOGGER = LoggerFactory.getLogger(FileInfo.class); private TByteArrayList bytes; // Stub @@ -125,4 +128,8 @@ public class FileInfo extends LRUObject { return true; } + @Override + public Logger getLogger() { + return LOGGER; + } } \ No newline at end of file diff --git a/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/LRU.java b/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/LRU.java index 48b7d4b10..b9ba72121 100644 --- a/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/LRU.java +++ b/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/LRU.java @@ -62,7 +62,7 @@ public class LRU> { 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> { 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> { } }); if (GraphClientImpl2.DEBUG) - System.err.println("Resuming LRU writers " + writers); + LOGGER.info("Resuming LRU writers " + writers); } /* diff --git a/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/LRUObject.java b/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/LRUObject.java index 508c95106..a84a28108 100644 --- a/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/LRUObject.java +++ b/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/LRUObject.java @@ -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> implements Persistable { - + + public abstract Logger getLogger(); public static boolean VERIFY = true; // Final stuff @@ -64,7 +66,7 @@ public abstract class LRUObject childContributions = new NodeTypeMultiMap(); @@ -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 allBrowseContextResources = BrowseContext.findSubcontexts(graph, browseContextResources); @@ -222,9 +224,9 @@ public class BrowseContext { Collection 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); } } diff --git a/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/labeldecorators/ConstantLabelDecorationRule.java b/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/labeldecorators/ConstantLabelDecorationRule.java index 2df8e52ee..5ba9ced6e 100644 --- a/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/labeldecorators/ConstantLabelDecorationRule.java +++ b/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/labeldecorators/ConstantLabelDecorationRule.java @@ -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."); } } diff --git a/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/nodetypes/SpecialNodeType.java b/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/nodetypes/SpecialNodeType.java index ddd6113ff..8218bac41 100644 --- a/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/nodetypes/SpecialNodeType.java +++ b/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/nodetypes/SpecialNodeType.java @@ -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); } diff --git a/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/tests/InstanceOfTest.java b/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/tests/InstanceOfTest.java index 70b6ecaa4..088889113 100644 --- a/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/tests/InstanceOfTest.java +++ b/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/tests/InstanceOfTest.java @@ -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; } diff --git a/bundles/org.simantics.g2d/META-INF/MANIFEST.MF b/bundles/org.simantics.g2d/META-INF/MANIFEST.MF index f5ed551cc..0a6fd2a0a 100644 --- a/bundles/org.simantics.g2d/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.g2d/META-INF/MANIFEST.MF @@ -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, diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/DiagramUtils.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/DiagramUtils.java index ed812c21a..8cfea8b59 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/DiagramUtils.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/DiagramUtils.java @@ -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; } diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/TerminalPainter.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/TerminalPainter.java index e4c7ac201..39baa912c 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/TerminalPainter.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/TerminalPainter.java @@ -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; } diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/dnd/DragPainter.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/dnd/DragPainter.java index 3ebccf136..feb712cd3 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/dnd/DragPainter.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/dnd/DragPainter.java @@ -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; } diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/gallery/GalleryViewer.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/gallery/GalleryViewer.java index 08ccf1f87..2e8ad5b66 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/gallery/GalleryViewer.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/gallery/GalleryViewer.java @@ -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 @@ -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; } diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/participant/MultitouchPanZoomRotateInteractor.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/participant/MultitouchPanZoomRotateInteractor.java index 3e1f625b8..95cd9c029 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/participant/MultitouchPanZoomRotateInteractor.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/participant/MultitouchPanZoomRotateInteractor.java @@ -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(); diff --git a/bundles/org.simantics.graph/src/org/simantics/graph/representation/TransferableGraphFileReader.java b/bundles/org.simantics.graph/src/org/simantics/graph/representation/TransferableGraphFileReader.java index 7f4cc3e9b..ae1ec711c 100644 --- a/bundles/org.simantics.graph/src/org/simantics/graph/representation/TransferableGraphFileReader.java +++ b/bundles/org.simantics.graph/src/org/simantics/graph/representation/TransferableGraphFileReader.java @@ -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 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 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)); } } diff --git a/bundles/org.simantics.issues.common/src/org/simantics/issues/common/DependencyIssueSynchronizer2.java b/bundles/org.simantics.issues.common/src/org/simantics/issues/common/DependencyIssueSynchronizer2.java index 1cb22d574..e31d5027e 100644 --- a/bundles/org.simantics.issues.common/src/org/simantics/issues/common/DependencyIssueSynchronizer2.java +++ b/bundles/org.simantics.issues.common/src/org/simantics/issues/common/DependencyIssueSynchronizer2.java @@ -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 existing = graph.syncRequest(new DependencyIssueDescriptions(source, resource), TransientCacheListener.>instance()); Set contexts = Collections.emptySet(); diff --git a/bundles/org.simantics.issues.common/src/org/simantics/issues/common/DependencyIssueValidator2.java b/bundles/org.simantics.issues.common/src/org/simantics/issues/common/DependencyIssueValidator2.java index 68905e57d..13e4961b3 100644 --- a/bundles/org.simantics.issues.common/src/org/simantics/issues/common/DependencyIssueValidator2.java +++ b/bundles/org.simantics.issues.common/src/org/simantics/issues/common/DependencyIssueValidator2.java @@ -64,7 +64,7 @@ public class DependencyIssueValidator2 extends ResourceRead3 { try { @SuppressWarnings("unchecked") Set contexts = new HashSet((List)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 { @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 existing = graph.syncRequest(new DependencyIssueDescriptions(resource3, resource), TransientCacheListener.>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 contexts = graph.syncRequest(new Contexts(resource3, resource), TransientCacheListener.>instance()); - if(DEBUG) System.err.println("Current: " + contexts.size() + " issues (" + contexts + ")"); + if(DEBUG) LOGGER.info("Current: " + contexts.size() + " issues (" + contexts + ")"); return existing.equals(contexts); diff --git a/bundles/org.simantics.issues.common/src/org/simantics/issues/common/IssueSourceUtils.java b/bundles/org.simantics.issues.common/src/org/simantics/issues/common/IssueSourceUtils.java index f79e90a47..32de2780a 100644 --- a/bundles/org.simantics.issues.common/src/org/simantics/issues/common/IssueSourceUtils.java +++ b/bundles/org.simantics.issues.common/src/org/simantics/issues/common/IssueSourceUtils.java @@ -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 data = graph.syncRequest(new Test3(component, types), TransientCacheAsyncListener.>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 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> index = MetadataUtils.getDependencyChangesFrom(graph, revisionId+1); diff --git a/bundles/org.simantics.mapping/META-INF/MANIFEST.MF b/bundles/org.simantics.mapping/META-INF/MANIFEST.MF index 46c07ed23..8f584dca5 100644 --- a/bundles/org.simantics.mapping/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.mapping/META-INF/MANIFEST.MF @@ -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, diff --git a/bundles/org.simantics.mapping/src/org/simantics/mapping/rule/instructions/QueryRuleInstruction.java b/bundles/org.simantics.mapping/src/org/simantics/mapping/rule/instructions/QueryRuleInstruction.java index dbb0e7ca4..404df9c48 100644 --- a/bundles/org.simantics.mapping/src/org/simantics/mapping/rule/instructions/QueryRuleInstruction.java +++ b/bundles/org.simantics.mapping/src/org/simantics/mapping/rule/instructions/QueryRuleInstruction.java @@ -11,18 +11,21 @@ *******************************************************************************/ 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; } diff --git a/bundles/org.simantics.message/META-INF/MANIFEST.MF b/bundles/org.simantics.message/META-INF/MANIFEST.MF index 5789861bb..355faba37 100644 --- a/bundles/org.simantics.message/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.message/META-INF/MANIFEST.MF @@ -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, diff --git a/bundles/org.simantics.message/src/org/simantics/message/internal/MessageSchemeManager.java b/bundles/org.simantics.message/src/org/simantics/message/internal/MessageSchemeManager.java index b9d62f53f..13eb635d0 100644 --- a/bundles/org.simantics.message/src/org/simantics/message/internal/MessageSchemeManager.java +++ b/bundles/org.simantics.message/src/org/simantics/message/internal/MessageSchemeManager.java @@ -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; } diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/MergeFlagsHandler.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/MergeFlagsHandler.java index a42691512..9a7b1055c 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/MergeFlagsHandler.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/MergeFlagsHandler.java @@ -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ö @@ -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 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 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 diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/ModelEvaluators.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/ModelEvaluators.java index 31a64fa48..25e57286f 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/ModelEvaluators.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/ModelEvaluators.java @@ -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ö @@ -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); + } }; } } diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/CompilePGraphs.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/CompilePGraphs.java index 7f7171dca..7781fbeff 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/CompilePGraphs.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/CompilePGraphs.java @@ -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; } diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/PartialIC.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/PartialIC.java index a777f655e..be5d86acc 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/PartialIC.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/PartialIC.java @@ -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); } } diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLTypeUtils.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLTypeUtils.java index d3c7310e4..c94b1be1b 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLTypeUtils.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLTypeUtils.java @@ -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 TYPE_MAP = new THashMap(); 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); } } diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/UserComponentMigration.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/UserComponentMigration.java index be480be47..928c405b5 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/UserComponentMigration.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/UserComponentMigration.java @@ -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 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); diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/migration/DocumentCleanupMigrationStep.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/migration/DocumentCleanupMigrationStep.java index 642434cc2..b9b1d1ac7 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/migration/DocumentCleanupMigrationStep.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/migration/DocumentCleanupMigrationStep.java @@ -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); } } diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/rules/MappedModelingRules.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/rules/MappedModelingRules.java index a47a1b63f..21a435f4a 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/rules/MappedModelingRules.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/rules/MappedModelingRules.java @@ -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) ); diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/scl/RouteGraphMatching.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/scl/RouteGraphMatching.java index b13ff6b75..61eee5511 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/scl/RouteGraphMatching.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/scl/RouteGraphMatching.java @@ -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 rs = new THashSet(); 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 components = (List) 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; } diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/services/CaseInsensitiveComponentNamingStrategy.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/services/CaseInsensitiveComponentNamingStrategy.java index ff1c17bd3..d2c15b5c4 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/services/CaseInsensitiveComponentNamingStrategy.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/services/CaseInsensitiveComponentNamingStrategy.java @@ -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 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 Set addToMapSet(ConcurrentMap> map, K key, V value) { diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/services/CaseInsensitiveComponentNamingStrategy2.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/services/CaseInsensitiveComponentNamingStrategy2.java index cd2c00b6d..a8a8a7319 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/services/CaseInsensitiveComponentNamingStrategy2.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/services/CaseInsensitiveComponentNamingStrategy2.java @@ -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) diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/userComponent/ComponentTypeCommands.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/userComponent/ComponentTypeCommands.java index cf6690c31..0afdb03b7 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/userComponent/ComponentTypeCommands.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/userComponent/ComponentTypeCommands.java @@ -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; } diff --git a/bundles/org.simantics.project/src/org/simantics/project/management/PlatformUtil.java b/bundles/org.simantics.project/src/org/simantics/project/management/PlatformUtil.java index d37947c4e..7655f9ca5 100644 --- a/bundles/org.simantics.project/src/org/simantics/project/management/PlatformUtil.java +++ b/bundles/org.simantics.project/src/org/simantics/project/management/PlatformUtil.java @@ -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; } diff --git a/bundles/org.simantics.scenegraph.loader/META-INF/MANIFEST.MF b/bundles/org.simantics.scenegraph.loader/META-INF/MANIFEST.MF index 93b3de91c..a1207fbb5 100644 --- a/bundles/org.simantics.scenegraph.loader/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.scenegraph.loader/META-INF/MANIFEST.MF @@ -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 diff --git a/bundles/org.simantics.scenegraph.loader/src/org/simantics/scenegraph/loader/ScenegraphLoaderUtils.java b/bundles/org.simantics.scenegraph.loader/src/org/simantics/scenegraph/loader/ScenegraphLoaderUtils.java index e40773002..b4b68a002 100644 --- a/bundles/org.simantics.scenegraph.loader/src/org/simantics/scenegraph/loader/ScenegraphLoaderUtils.java +++ b/bundles/org.simantics.scenegraph.loader/src/org/simantics/scenegraph/loader/ScenegraphLoaderUtils.java @@ -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, Collection>> externalMap = new HashMap, Collection>>(); static Map, Object> externalValueMap = new HashMap, 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; } diff --git a/bundles/org.simantics.scenegraph/src/com/infomatiq/jsi/PriorityQueue.java b/bundles/org.simantics.scenegraph/src/com/infomatiq/jsi/PriorityQueue.java index 3b402a86a..150726681 100644 --- a/bundles/org.simantics.scenegraph/src/com/infomatiq/jsi/PriorityQueue.java +++ b/bundles/org.simantics.scenegraph/src/com/infomatiq/jsi/PriorityQueue.java @@ -19,6 +19,10 @@ 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"); } } } diff --git a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/SVGNode.java b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/SVGNode.java index 6fd25e6f8..fe3fe5e9d 100644 --- a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/SVGNode.java +++ b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/SVGNode.java @@ -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; } } diff --git a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/provisional/GraphPropertyNode.java b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/provisional/GraphPropertyNode.java index b9ce6c012..ce353b108 100644 --- a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/provisional/GraphPropertyNode.java +++ b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/provisional/GraphPropertyNode.java @@ -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, Map> fieldCache = new ConcurrentHashMap, Map>(); @@ -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 { diff --git a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/utils/MipMapVRamBufferedImage.java b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/utils/MipMapVRamBufferedImage.java index 26717bc93..54323097b 100644 --- a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/utils/MipMapVRamBufferedImage.java +++ b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/utils/MipMapVRamBufferedImage.java @@ -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; } diff --git a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/utils/NodeUtil.java b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/utils/NodeUtil.java index 9439369a5..5dac6fd2a 100644 --- a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/utils/NodeUtil.java +++ b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/utils/NodeUtil.java @@ -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 */ @@ -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 " + 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 " + 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 " + result); + LOGGER.warn("=getLocalBoundsImpl " + node + " => " + result); } return result; } diff --git a/bundles/org.simantics.scl.commands/META-INF/MANIFEST.MF b/bundles/org.simantics.scl.commands/META-INF/MANIFEST.MF index b136c78ef..feaa6ed6e 100644 --- a/bundles/org.simantics.scl.commands/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.scl.commands/META-INF/MANIFEST.MF @@ -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 diff --git a/bundles/org.simantics.scl.commands/src/org/simantics/scl/commands/internal/serialization/CommandSerializerFactory.java b/bundles/org.simantics.scl.commands/src/org/simantics/scl/commands/internal/serialization/CommandSerializerFactory.java index 6f24e7d71..70d2ad6a2 100644 --- a/bundles/org.simantics.scl.commands/src/org/simantics/scl/commands/internal/serialization/CommandSerializerFactory.java +++ b/bundles/org.simantics.scl.commands/src/org/simantics/scl/commands/internal/serialization/CommandSerializerFactory.java @@ -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[] 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); } } diff --git a/bundles/org.simantics.scl.commands/src/org/simantics/scl/commands/internal/serialization/ErrorSerializer.java b/bundles/org.simantics.scl.commands/src/org/simantics/scl/commands/internal/serialization/ErrorSerializer.java index 77048b2fe..1c7c479d4 100644 --- a/bundles/org.simantics.scl.commands/src/org/simantics/scl/commands/internal/serialization/ErrorSerializer.java +++ b/bundles/org.simantics.scl.commands/src/org/simantics/scl/commands/internal/serialization/ErrorSerializer.java @@ -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 + "."); } } diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/references/ValRef.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/references/ValRef.java index 85a613c43..954e8d0a3 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/references/ValRef.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/references/ValRef.java @@ -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 diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/utils/SSAValidationContext.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/utils/SSAValidationContext.java index 923acdba2..22c7c7429 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/utils/SSAValidationContext.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/utils/SSAValidationContext.java @@ -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 validBoundVariables = new THashSet(); public THashSet validContinuations = new THashSet(); public THashSet validTypeVariables = new THashSet(); @@ -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; } diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/types/TVarAst.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/types/TVarAst.java index 84d3e3a01..cf5a7a862 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/types/TVarAst.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/types/TVarAst.java @@ -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; diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/markdown/html/SCLDocumentationExtensionNodeHandler.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/markdown/html/SCLDocumentationExtensionNodeHandler.java index bec138283..d9e65e28c 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/markdown/html/SCLDocumentationExtensionNodeHandler.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/markdown/html/SCLDocumentationExtensionNodeHandler.java @@ -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("
")); } @@ -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("")); @@ -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)); } } diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/parser/generator/table/ParseTableBuilder.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/parser/generator/table/ParseTableBuilder.java index fdb01e58d..c18694643 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/parser/generator/table/ParseTableBuilder.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/parser/generator/table/ParseTableBuilder.java @@ -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 "); + 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; } diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/parser/grammar/Grammar.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/parser/grammar/Grammar.java index e80858c55..f7db0d9cd 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/parser/grammar/Grammar.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/parser/grammar/Grammar.java @@ -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 - diff --git a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/AbstractCommandConsole.java b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/AbstractCommandConsole.java index a293eaee1..ab9e033d0 100644 --- a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/AbstractCommandConsole.java +++ b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/AbstractCommandConsole.java @@ -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(); } diff --git a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/SCLConsole.java b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/SCLConsole.java index 9207bef39..7221158c1 100644 --- a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/SCLConsole.java +++ b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/SCLConsole.java @@ -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 index 000000000..d333f235a --- /dev/null +++ b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/outline/SCLModuleOutlinePage.java @@ -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(); + } + + } +} diff --git a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetReferenceResolver.java b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetReferenceResolver.java index 78f5c68d1..6428f9b83 100644 --- a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetReferenceResolver.java +++ b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetReferenceResolver.java @@ -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 { @@ -15,5 +17,9 @@ public class SpreadsheetReferenceResolver extends ReferenceResolverBase { public SpreadsheetSynchronizationEventHandler(ReadGraph graph, SpreadsheetBook book) { super(book, new SpreadsheetReferenceResolver(book), book, book, book, book.getMapping()); } - + + @Override + public Logger getLogger() { + return LoggerFactory.getLogger(getClass()); + } + } diff --git a/bundles/org.simantics.structural.synchronization.client/META-INF/MANIFEST.MF b/bundles/org.simantics.structural.synchronization.client/META-INF/MANIFEST.MF index e86311f32..eae812672 100644 --- a/bundles/org.simantics.structural.synchronization.client/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.structural.synchronization.client/META-INF/MANIFEST.MF @@ -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 diff --git a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ReferenceResolverBase.java b/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ReferenceResolverBase.java index ef781f3df..7fabc6747 100644 --- a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ReferenceResolverBase.java +++ b/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ReferenceResolverBase.java @@ -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> { @@ -92,7 +93,7 @@ abstract public class ReferenceResolverBase> { 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> { } }); 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(); } diff --git a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/SynchronizationEventHandlerBase.java b/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/SynchronizationEventHandlerBase.java index 94bfbf896..82dd224b6 100644 --- a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/SynchronizationEventHandlerBase.java +++ b/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/SynchronizationEventHandlerBase.java @@ -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 } 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 public long getFromRevision() { return mapping.currentRevision; } + + public abstract Logger getLogger(); } diff --git a/bundles/org.simantics.structural.synchronization/META-INF/MANIFEST.MF b/bundles/org.simantics.structural.synchronization/META-INF/MANIFEST.MF index ad9b7fe56..787d2c567 100644 --- a/bundles/org.simantics.structural.synchronization/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.structural.synchronization/META-INF/MANIFEST.MF @@ -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 diff --git a/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/utils/DiagnosticSynchronizationEventHandler.java b/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/utils/DiagnosticSynchronizationEventHandler.java index f316cbfc7..974c63246 100644 --- a/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/utils/DiagnosticSynchronizationEventHandler.java +++ b/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/utils/DiagnosticSynchronizationEventHandler.java @@ -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 properties, Collection connections, Collection children) throws SynchronizationException { + StringBuilder indent = new StringBuilder(); for(int i=0;i 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); } } diff --git a/bundles/org.simantics.structural2/src/org/simantics/structural2/variables/StandardProceduralChildVariable.java b/bundles/org.simantics.structural2/src/org/simantics/structural2/variables/StandardProceduralChildVariable.java index 0db9d7033..a5b50f6f3 100644 --- a/bundles/org.simantics.structural2/src/org/simantics/structural2/variables/StandardProceduralChildVariable.java +++ b/bundles/org.simantics.structural2/src/org/simantics/structural2/variables/StandardProceduralChildVariable.java @@ -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; diff --git a/bundles/org.simantics.trend/META-INF/MANIFEST.MF b/bundles/org.simantics.trend/META-INF/MANIFEST.MF index 1daf9cc51..fa1ce29bd 100644 --- a/bundles/org.simantics.trend/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.trend/META-INF/MANIFEST.MF @@ -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, diff --git a/bundles/org.simantics.trend/src/org/simantics/trend/impl/ItemNode.java b/bundles/org.simantics.trend/src/org/simantics/trend/impl/ItemNode.java index dcbd1c797..c866d2cc2 100644 --- a/bundles/org.simantics.trend/src/org/simantics/trend/impl/ItemNode.java +++ b/bundles/org.simantics.trend/src/org/simantics/trend/impl/ItemNode.java @@ -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 diff --git a/bundles/org.simantics.ui/src/org/simantics/ui/jobs/SessionGarbageCollectorJob.java b/bundles/org.simantics.ui/src/org/simantics/ui/jobs/SessionGarbageCollectorJob.java index 1805d0dab..d987c3444 100644 --- a/bundles/org.simantics.ui/src/org/simantics/ui/jobs/SessionGarbageCollectorJob.java +++ b/bundles/org.simantics.ui/src/org/simantics/ui/jobs/SessionGarbageCollectorJob.java @@ -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. diff --git a/bundles/org.simantics.ui/src/org/simantics/ui/workbench/WorkbenchShutdownServiceImpl.java b/bundles/org.simantics.ui/src/org/simantics/ui/workbench/WorkbenchShutdownServiceImpl.java index 6a1b2c027..9cba52a37 100644 --- a/bundles/org.simantics.ui/src/org/simantics/ui/workbench/WorkbenchShutdownServiceImpl.java +++ b/bundles/org.simantics.ui/src/org/simantics/ui/workbench/WorkbenchShutdownServiceImpl.java @@ -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 hooks = new ArrayList(); @@ -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); } } diff --git a/bundles/org.simantics.utils.thread/META-INF/MANIFEST.MF b/bundles/org.simantics.utils.thread/META-INF/MANIFEST.MF index 44435fa6e..d55b3da70 100644 --- a/bundles/org.simantics.utils.thread/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.utils.thread/META-INF/MANIFEST.MF @@ -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 diff --git a/bundles/org.simantics.utils.thread/src/org/simantics/utils/threads/ThreadUtils.java b/bundles/org.simantics.utils.thread/src/org/simantics/utils/threads/ThreadUtils.java index e9a6fa4e3..cd8d6027e 100644 --- a/bundles/org.simantics.utils.thread/src/org/simantics/utils/threads/ThreadUtils.java +++ b/bundles/org.simantics.utils.thread/src/org/simantics/utils/threads/ThreadUtils.java @@ -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 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 diff --git a/bundles/org.simantics.utils.ui/META-INF/MANIFEST.MF b/bundles/org.simantics.utils.ui/META-INF/MANIFEST.MF index 9790dcd06..132a74a80 100644 --- a/bundles/org.simantics.utils.ui/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.utils.ui/META-INF/MANIFEST.MF @@ -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, diff --git a/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/widgets/TrackedStyledText.java b/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/widgets/TrackedStyledText.java index 864c68402..0c3b9763a 100644 --- a/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/widgets/TrackedStyledText.java +++ b/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/widgets/TrackedStyledText.java @@ -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); diff --git a/bundles/org.simantics.utils/src/org/simantics/utils/Development.java b/bundles/org.simantics.utils/src/org/simantics/utils/Development.java index afaec5c32..84c13b4d8 100644 --- a/bundles/org.simantics.utils/src/org/simantics/utils/Development.java +++ b/bundles/org.simantics.utils/src/org/simantics/utils/Development.java @@ -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 histogram = new TreeMap(); 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); } } diff --git a/tests/org.simantics.scl.compiler.tests/META-INF/MANIFEST.MF b/tests/org.simantics.scl.compiler.tests/META-INF/MANIFEST.MF index 710abbf56..5cfd3d987 100644 --- a/tests/org.simantics.scl.compiler.tests/META-INF/MANIFEST.MF +++ b/tests/org.simantics.scl.compiler.tests/META-INF/MANIFEST.MF @@ -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 diff --git a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/MemoryLeakExperiment.java b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/MemoryLeakExperiment.java index 76cd51e90..29c190623 100644 --- a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/MemoryLeakExperiment.java +++ b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/MemoryLeakExperiment.java @@ -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"); } } } diff --git a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/TestCommandSession.java b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/TestCommandSession.java index 784a80b4c..ffeaa6b6f 100644 --- a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/TestCommandSession.java +++ b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/TestCommandSession.java @@ -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); } }; diff --git a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/TestExpressionEvaluator.java b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/TestExpressionEvaluator.java index 2e887ca1a..b78d48528 100644 --- a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/TestExpressionEvaluator.java +++ b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/TestExpressionEvaluator.java @@ -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