From: Hannu Niemistö Date: Mon, 26 Sep 2016 06:08:29 +0000 (+0300) Subject: Utilize slf4j X-Git-Tag: v1.25.0~93 X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=commitdiff_plain;h=72fb2b54adeee15fa47deb223e69d2dbfb2ab83f;hp=4cf3ca93d6e26c7434259fcf38b4d9db3c681a6f Utilize slf4j Changed System.out/err prints to use logging in several places. Removed org.simantics.Logging and replaced all uses by slf4j. Change-Id: Ib0a9f4f87b945fd59130a9dfd02fe02d39ee0eac --- diff --git a/bundles/org.simantics.annotation.ui/META-INF/MANIFEST.MF b/bundles/org.simantics.annotation.ui/META-INF/MANIFEST.MF index e962c736e..9435da36d 100644 --- a/bundles/org.simantics.annotation.ui/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.annotation.ui/META-INF/MANIFEST.MF @@ -16,7 +16,8 @@ Require-Bundle: org.eclipse.ui, org.simantics.browsing.ui.model;bundle-version="1.0.0", org.simantics.modeling.ui;bundle-version="1.1.1", org.simantics.graph.db;bundle-version="1.1.9", - org.simantics.views.swt.client;bundle-version="1.0.0" + org.simantics.views.swt.client;bundle-version="1.0.0", + org.slf4j.api;bundle-version="1.7.20" Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-Vendor: VTT Technical Research Centre of Finland diff --git a/bundles/org.simantics.annotation.ui/src/org/simantics/annotation/ui/SCL.java b/bundles/org.simantics.annotation.ui/src/org/simantics/annotation/ui/SCL.java index 7a7977f33..f4f99997c 100644 --- a/bundles/org.simantics.annotation.ui/src/org/simantics/annotation/ui/SCL.java +++ b/bundles/org.simantics.annotation.ui/src/org/simantics/annotation/ui/SCL.java @@ -34,7 +34,6 @@ import org.simantics.db.VirtualGraph; import org.simantics.db.WriteGraph; import org.simantics.db.common.request.UnaryRead; import org.simantics.db.common.request.WriteRequest; -import org.simantics.db.common.utils.Logger; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.util.Layer0Utils; import org.simantics.db.layer0.util.RemoverUtil; @@ -60,6 +59,8 @@ import org.simantics.utils.strings.AlphanumComparator; import org.simantics.utils.ui.ISelectionUtils; import org.simantics.views.swt.client.base.ISWTViewNode; import org.simantics.views.swt.client.impl.SWTExplorer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; @@ -69,6 +70,8 @@ import gnu.trove.set.hash.THashSet; * @author Tuukka Lehtonen */ public class SCL { + + private static final Logger LOGGER = LoggerFactory.getLogger(SCL.class); final public static String EMPTY = ""; final public static String MAPPED = "Mapped"; @@ -493,7 +496,7 @@ public class SCL { try { doAdd((Variable)properties.input); } catch (DatabaseException e) { - Logger.defaultLogError(e); + LOGGER.error("newAnnotationModifier failed", e); } return null; @@ -670,7 +673,7 @@ public class SCL { String name = graph.getPossibleRelatedValue(r, L0.HasName, Bindings.STRING); if(name != null) { if (result.put(name, r) != null) - System.err.println(this + ": The database contains siblings with the same name " + name + " (resource=$" + resource.getResourceId() +")."); + LOGGER.error("The database contains siblings with the same name " + name + " (resource=$" + resource.getResourceId() +")."); } } return result; diff --git a/bundles/org.simantics.db.common/META-INF/MANIFEST.MF b/bundles/org.simantics.db.common/META-INF/MANIFEST.MF index 89395e6ea..5ba6379d6 100644 --- a/bundles/org.simantics.db.common/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.db.common/META-INF/MANIFEST.MF @@ -14,7 +14,8 @@ Require-Bundle: org.simantics.db;bundle-version="1.1.0";visibility:=reexport, org.simantics.scl.runtime;bundle-version="0.1.4", org.simantics.user.ontology;bundle-version="1.0.0", org.simantics.layer0x.ontology;bundle-version="1.0.0", - org.simantics.issues.ontology;bundle-version="1.2.0" + org.simantics.issues.ontology;bundle-version="1.2.0", + org.slf4j.api Export-Package: org.simantics.db.common, org.simantics.db.common.adaption, org.simantics.db.common.auth, diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/PropertyMapOfResource.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/PropertyMapOfResource.java index 5a92ef62c..1d06cc33d 100644 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/PropertyMapOfResource.java +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/PropertyMapOfResource.java @@ -22,9 +22,13 @@ import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.exception.DatabaseException; import org.simantics.layer0.Layer0; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PropertyMapOfResource extends ResourceRead> { + private static final Logger LOGGER = LoggerFactory.getLogger(PropertyMapOfResource.class); + public PropertyMapOfResource(Resource resource) { super(resource); } @@ -41,7 +45,7 @@ public class PropertyMapOfResource extends ResourceRead> { if(name != null) { String escapedName = URIStringUtils.escape(name); if (result.put(escapedName, predicate) != null) - System.err.println(this + ": The database contains siblings with the same name " + name + " (resource=$" + resource.getResourceId() +")."); + LOGGER.error("The database contains siblings with the same name " + name + " (resource=$" + resource.getResourceId() +")."); } } } diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/uri/EscapedChildMapOfResource.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/uri/EscapedChildMapOfResource.java index 99b20ff73..1d92da9c8 100644 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/uri/EscapedChildMapOfResource.java +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/uri/EscapedChildMapOfResource.java @@ -20,12 +20,17 @@ import org.simantics.db.Resource; import org.simantics.db.common.ProcedureBarrier; import org.simantics.db.common.WriteBindings; import org.simantics.db.common.procedure.adapter.AsyncMultiProcedureAdapter; +import org.simantics.db.common.request.PropertyMapOfResource; import org.simantics.db.common.request.ResourceAsyncRead; import org.simantics.db.procedure.AsyncProcedure; import org.simantics.layer0.Layer0; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class EscapedChildMapOfResource extends ResourceAsyncRead> { + private static final Logger LOGGER = LoggerFactory.getLogger(EscapedChildMapOfResource.class); + public EscapedChildMapOfResource(Resource resource) { super(resource); } @@ -50,7 +55,7 @@ public class EscapedChildMapOfResource extends ResourceAsyncRead> { + private static final Logger LOGGER = LoggerFactory.getLogger(UnescapedChildMapOfResource.class); + public UnescapedChildMapOfResource(Resource resource) { super(resource); } @@ -40,10 +44,10 @@ public class UnescapedChildMapOfResource extends ResourceRead> { + private static final Logger LOGGER = LoggerFactory.getLogger(DocumentHistoryListener.class); final private DocumentHistory history; @@ -32,7 +34,7 @@ public class DocumentHistoryListener implements Listener> { @Override public void exception(Throwable t) { - Logger.defaultLogError(t); + LOGGER.warn("DocumentHistoryListener received an exception.", t); } @Override diff --git a/bundles/org.simantics.document.server/src/org/simantics/document/server/request/NodeRequestUtils.java b/bundles/org.simantics.document.server/src/org/simantics/document/server/request/NodeRequestUtils.java index 26f88608f..2e67010eb 100644 --- a/bundles/org.simantics.document.server/src/org/simantics/document/server/request/NodeRequestUtils.java +++ b/bundles/org.simantics.document.server/src/org/simantics/document/server/request/NodeRequestUtils.java @@ -4,15 +4,17 @@ import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.io.UnsupportedEncodingException; -import org.simantics.Logger; import org.simantics.db.layer0.exception.MissingVariableException; import org.simantics.db.layer0.scl.SCLDatabaseException; import org.simantics.document.server.DocumentException; import org.simantics.scl.compiler.module.repository.ImportFailure; import org.simantics.scl.compiler.module.repository.ImportFailureException; import org.simantics.scl.compiler.top.NotFoundException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class NodeRequestUtils { + private static final Logger LOGGER = LoggerFactory.getLogger(NodeRequestUtils.class); public static String formatErrorMessage(String name, Throwable t) { @@ -36,8 +38,8 @@ public class NodeRequestUtils { sb.append(" " + f.moduleName + "\n"); return sb.toString(); } else { - Logger.defaultLogError(t); - + LOGGER.error("Node request error:", t); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); t.printStackTrace(ps); diff --git a/bundles/org.simantics.export.core/META-INF/MANIFEST.MF b/bundles/org.simantics.export.core/META-INF/MANIFEST.MF index eadcf7e08..88dfc79c7 100644 --- a/bundles/org.simantics.export.core/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.export.core/META-INF/MANIFEST.MF @@ -15,7 +15,8 @@ Require-Bundle: org.eclipse.core.runtime, org.simantics.utils.ui;bundle-version="1.1.0", org.simantics.graph.db;bundle-version="1.1.9", org.simantics;bundle-version="1.0.0", - com.lowagie.text;bundle-version="2.1.7";resolution:=optional + com.lowagie.text;bundle-version="2.1.7";resolution:=optional, + org.slf4j.api Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Export-Package: org.simantics.export.core, org.simantics.export.core.error, diff --git a/bundles/org.simantics.export.core/src/org/simantics/export/core/pdf/ServiceBasedPdfExportPageEvent.java b/bundles/org.simantics.export.core/src/org/simantics/export/core/pdf/ServiceBasedPdfExportPageEvent.java index c513654df..65cb53d13 100644 --- a/bundles/org.simantics.export.core/src/org/simantics/export/core/pdf/ServiceBasedPdfExportPageEvent.java +++ b/bundles/org.simantics.export.core/src/org/simantics/export/core/pdf/ServiceBasedPdfExportPageEvent.java @@ -20,8 +20,9 @@ import java.util.function.Consumer; import org.osgi.framework.BundleContext; import org.osgi.framework.InvalidSyntaxException; import org.osgi.framework.ServiceReference; -import org.simantics.Logger; import org.simantics.export.core.internal.Activator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.lowagie.text.Document; import com.lowagie.text.Paragraph; @@ -34,6 +35,7 @@ import com.lowagie.text.pdf.PdfWriter; * @since 1.22.2 */ public class ServiceBasedPdfExportPageEvent extends PdfPageEventHelper { + private static final Logger LOGGER = LoggerFactory.getLogger(ServiceBasedPdfExportPageEvent.class); Map events; @@ -64,7 +66,7 @@ public class ServiceBasedPdfExportPageEvent extends PdfPageEventHelper { try { r.accept(event); } catch (Exception e) { - Logger.defaultLogError("Failed to invoke PdfExportPageEvent::" + eventName + " for " + event.toString(), e); + LOGGER.error("Failed to invoke PdfExportPageEvent::" + eventName + " for " + event.toString(), e); } } diff --git a/bundles/org.simantics.help.ui/META-INF/MANIFEST.MF b/bundles/org.simantics.help.ui/META-INF/MANIFEST.MF index e9f8ba1b9..0bc7d909d 100644 --- a/bundles/org.simantics.help.ui/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.help.ui/META-INF/MANIFEST.MF @@ -12,7 +12,8 @@ Require-Bundle: org.eclipse.ui, org.eclipse.ui.editors;bundle-version="3.9.0", org.eclipse.jface.text;bundle-version="3.10.0", org.eclipse.core.resources;bundle-version="3.10.1", - org.simantics.help.core + org.simantics.help.core, + org.slf4j.api Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy Bundle-ClassPath: . diff --git a/bundles/org.simantics.help.ui/src/org/simantics/help/ui/OpenHelpFileAdapter.java b/bundles/org.simantics.help.ui/src/org/simantics/help/ui/OpenHelpFileAdapter.java index c5847ce0d..6a5e2d968 100644 --- a/bundles/org.simantics.help.ui/src/org/simantics/help/ui/OpenHelpFileAdapter.java +++ b/bundles/org.simantics.help.ui/src/org/simantics/help/ui/OpenHelpFileAdapter.java @@ -2,7 +2,6 @@ package org.simantics.help.ui; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; -import org.simantics.Logger; import org.simantics.Simantics; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; @@ -16,8 +15,11 @@ import org.simantics.help.HelpResources; import org.simantics.ui.workbench.ResourceEditorInput2; import org.simantics.ui.workbench.editor.AbstractResourceEditorAdapter; import org.simantics.utils.ui.workbench.WorkbenchUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class OpenHelpFileAdapter extends AbstractResourceEditorAdapter { + private static final Logger LOGGER = LoggerFactory.getLogger(OpenHelpFileAdapter.class); public OpenHelpFileAdapter() { super("Help File Editor"); @@ -49,7 +51,7 @@ public class OpenHelpFileAdapter extends AbstractResourceEditorAdapter { String editorId = getEditorId(); WorkbenchUtils.openEditor(editorId, new ResourceEditorInput2(editorId, input, model, rvi)); } catch (PartInitException e) { - Logger.defaultLogError(e); + LOGGER.error("Failed to open an editor for help file.", e); } } }); diff --git a/bundles/org.simantics.issues.common/META-INF/MANIFEST.MF b/bundles/org.simantics.issues.common/META-INF/MANIFEST.MF index 421606517..23b688bcd 100644 --- a/bundles/org.simantics.issues.common/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.issues.common/META-INF/MANIFEST.MF @@ -11,7 +11,8 @@ Require-Bundle: org.simantics.issues;bundle-version="1.1.0", org.simantics.layer0.utils;bundle-version="0.6.2", org.simantics.db.services;bundle-version="0.6.2", org.simantics;bundle-version="1.0.0", - org.simantics.issues.ui.ontology;bundle-version="1.0.0" + org.simantics.issues.ui.ontology;bundle-version="1.0.0", + org.slf4j.api Export-Package: org.simantics.issues.common, org.simantics.issues.common.preferences Bundle-Vendor: VTT Technical Research Centre of Finland 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 7c6cdeccf..2f8c42b90 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 @@ -5,7 +5,6 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import org.simantics.Logger; import org.simantics.db.Issue; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; @@ -17,8 +16,11 @@ import org.simantics.db.common.utils.NameUtils; import org.simantics.db.exception.DatabaseException; import org.simantics.issues.ontology.IssueResource; import org.simantics.layer0.Layer0; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class DependencyIssueValidator2 extends ResourceRead3 { + private static final Logger LOGGER = LoggerFactory.getLogger(DependencyIssueValidator2.class); public static final boolean DEBUG = false; @@ -65,7 +67,7 @@ public class DependencyIssueValidator2 extends ResourceRead3 { if(DEBUG) System.err.println("Validator found: " + contexts.size() + " issues (" + contexts + ")"); return contexts; } catch (DatabaseException e) { - Logger.defaultLogError(e); + LOGGER.error("Reading a constraint validator failed", e); return Collections.emptySet(); } diff --git a/bundles/org.simantics.issues.common/src/org/simantics/issues/common/IssueUtils.java b/bundles/org.simantics.issues.common/src/org/simantics/issues/common/IssueUtils.java index 26f0167ad..f1dcadc89 100644 --- a/bundles/org.simantics.issues.common/src/org/simantics/issues/common/IssueUtils.java +++ b/bundles/org.simantics.issues.common/src/org/simantics/issues/common/IssueUtils.java @@ -25,7 +25,6 @@ import java.util.Set; import java.util.UUID; import java.util.concurrent.atomic.AtomicBoolean; -import org.simantics.Logger; import org.simantics.Simantics; import org.simantics.databoard.Bindings; import org.simantics.databoard.util.URIStringUtils; @@ -57,11 +56,14 @@ import org.simantics.layer0.Layer0; import org.simantics.operation.Layer0X; import org.simantics.scl.runtime.function.FunctionImpl2; import org.simantics.utils.datastructures.Pair; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Tuukka Lehtonen */ public class IssueUtils { + private static final Logger LOGGER = LoggerFactory.getLogger(IssueUtils.class); public static Resource toSeverityResource(IssueResource ISSUE, Severity severity) { switch (severity) { @@ -113,7 +115,7 @@ public class IssueUtils { }); } } catch (DatabaseException e) { - Logger.defaultLogError(e); + LOGGER.error("Updating issue source failed.", e); } } else { Session session = Simantics.getSession(); @@ -173,7 +175,7 @@ public class IssueUtils { @Override public void exception(ReadGraph graph, Throwable throwable) throws DatabaseException { - Logger.defaultLogError(throwable); + LOGGER.error("IssueValidityListener received an exception.", throwable); } } @@ -207,7 +209,7 @@ public class IssueUtils { @Override public void exception(ReadGraph graph, Throwable t) { - Logger.defaultLogError(t); + LOGGER.error("IssueSourceManagedIssuesListener received an exception.", t); } @Override @@ -263,7 +265,7 @@ public class IssueUtils { @Override public void exception(ReadGraph graph, Throwable t) { - Logger.defaultLogError(t); + LOGGER.error("ActiveIssueSourceListener received an exception.", t); } @Override diff --git a/bundles/org.simantics.modeling.ui/META-INF/MANIFEST.MF b/bundles/org.simantics.modeling.ui/META-INF/MANIFEST.MF index 76aec39f3..f396a5815 100644 --- a/bundles/org.simantics.modeling.ui/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.modeling.ui/META-INF/MANIFEST.MF @@ -61,7 +61,8 @@ Require-Bundle: org.simantics.project;bundle-version="1.0.0", org.simantics.db.layer0, org.simantics.silk.ontology;bundle-version="1.1.0", org.simantics.image.ui;bundle-version="1.0.0", - org.simantics.export.core;bundle-version="1.0.0" + org.simantics.export.core;bundle-version="1.0.0", + org.slf4j.api Export-Package: org.simantics.modeling.ui, org.simantics.modeling.ui.actions, org.simantics.modeling.ui.chart.property, diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/ModeledActions.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/ModeledActions.java index 47d5643a1..ea50134d7 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/ModeledActions.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/ModeledActions.java @@ -33,7 +33,6 @@ import org.eclipse.jface.action.ActionContributionItem; import org.eclipse.jface.action.IContributionItem; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; -import org.simantics.Logger; import org.simantics.browsing.ui.NodeContext; import org.simantics.browsing.ui.common.NodeContextBuilder; import org.simantics.browsing.ui.model.InvalidContribution; @@ -42,13 +41,17 @@ import org.simantics.browsing.ui.model.actions.IActionCategory; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.exception.DatabaseException; +import org.simantics.issues.common.IssueUtils; import org.simantics.modeling.ui.Activator; import org.simantics.project.ontology.ProjectResource; import org.simantics.ui.contribution.DynamicMenuContribution; import org.simantics.ui.selection.WorkbenchSelectionElement; import org.simantics.ui.selection.WorkbenchSelectionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ModeledActions extends DynamicMenuContribution implements IExecutableExtension { + private static final Logger LOGGER = LoggerFactory.getLogger(IssueUtils.class); public static final Set defaultBrowseContexts = Collections.singleton(ProjectResource.URIs.ProjectActionContext); @@ -121,7 +124,7 @@ public class ModeledActions extends DynamicMenuContribution implements IExecutab result.add(NodeContextBuilder.buildWithInput(res)); } } catch (DatabaseException e) { - Logger.defaultLogError(e); + LOGGER.error("Failed to get node contexts for selection.", e); } } } diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/ConfigurationPropertiesSection.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/ConfigurationPropertiesSection.java index 1ad4cd539..477a5543b 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/ConfigurationPropertiesSection.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/ConfigurationPropertiesSection.java @@ -38,7 +38,6 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.forms.widgets.Form; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Section; -import org.simantics.Logger; import org.simantics.Simantics; import org.simantics.databoard.Bindings; import org.simantics.db.ReadGraph; @@ -63,9 +62,13 @@ import org.simantics.modeling.userComponent.ComponentTypeCommands; import org.simantics.selectionview.SelectionViewResources; import org.simantics.structural.stubs.StructuralResource2; import org.simantics.utils.datastructures.Pair; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ConfigurationPropertiesSection implements ComponentTypeViewerSection { + private static final Logger LOGGER = LoggerFactory.getLogger(ConfigurationPropertiesSection.class); + private static final String[] COLUMN_NAMES = new String[] {"Name", "Type", "Default Value", "Unit", "Range", "Label", "Description"}; private static final int[] COLUMN_LENGTHS = @@ -443,7 +446,7 @@ public class ConfigurationPropertiesSection implements ComponentTypeViewerSectio } catch (DatabaseException e1) { - Logger.defaultLogError(e1); + LOGGER.error("Lifting properties failed", e1); return; } @@ -565,7 +568,7 @@ public class ConfigurationPropertiesSection implements ComponentTypeViewerSectio } }); } catch (DatabaseException e) { - Logger.defaultLogError(e); + LOGGER.error("Finding UserDefinedProperties failed.", e); return Collections.emptyMap(); } } diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/OpenSheetAdapter.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/OpenSheetAdapter.java index 207257baa..0a4ca49b4 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/OpenSheetAdapter.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/OpenSheetAdapter.java @@ -13,7 +13,6 @@ package org.simantics.modeling.ui.diagramEditor; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; -import org.simantics.Logger; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.common.request.PossibleIndexRoot; @@ -28,8 +27,11 @@ import org.simantics.ui.SimanticsUI; import org.simantics.ui.workbench.ResourceEditorInput2; import org.simantics.ui.workbench.editor.AbstractResourceEditorAdapter; import org.simantics.utils.ui.workbench.WorkbenchUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class OpenSheetAdapter extends AbstractResourceEditorAdapter { + private static final Logger LOGGER = LoggerFactory.getLogger(OpenSheetAdapter.class); private static final String EDITOR_ID = "org.simantics.spreadsheet.ui.editor2"; @@ -63,7 +65,7 @@ public class OpenSheetAdapter extends AbstractResourceEditorAdapter { String editorId = getEditorId(); WorkbenchUtils.openEditor(editorId, new ResourceEditorInput2(editorId, r, model, rvi)); } catch (PartInitException e) { - Logger.defaultLogError(e); + LOGGER.error("Failed to open the spreadsheet editor.", e); } } }); diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/PopulateElementMonitorDropParticipant.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/PopulateElementMonitorDropParticipant.java index 0deeb1be1..959bbbe6f 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/PopulateElementMonitorDropParticipant.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/PopulateElementMonitorDropParticipant.java @@ -11,8 +11,6 @@ *******************************************************************************/ package org.simantics.modeling.ui.diagramEditor; -import gnu.trove.set.hash.THashSet; - import java.awt.datatransfer.Transferable; import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.dnd.DnDConstants; @@ -25,7 +23,6 @@ import java.util.HashMap; import java.util.List; import org.eclipse.jface.viewers.IStructuredSelection; -import org.simantics.Logger; import org.simantics.db.ReadGraph; import org.simantics.db.RequestProcessor; import org.simantics.db.Resource; @@ -64,8 +61,13 @@ import org.simantics.ui.selection.WorkbenchSelectionUtils; import org.simantics.utils.datastructures.Triple; import org.simantics.utils.datastructures.hints.IHintContext; import org.simantics.utils.ui.ISelectionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import gnu.trove.set.hash.THashSet; public class PopulateElementMonitorDropParticipant extends PopulateElementDropParticipant implements IDropTargetParticipant { + private static final Logger LOGGER = LoggerFactory.getLogger(PopulateElementMonitorDropParticipant.class); private static final boolean DEBUG = false; @@ -129,14 +131,9 @@ public class PopulateElementMonitorDropParticipant extends PopulateElementDropPa dp.getHints().setHint(DnDHints.KEY_DND_GRID_COLUMNS, Integer.valueOf(1)); } - } catch (UnsupportedFlavorException e) { - Logger.defaultLogError(e); - } catch (IOException e) { - Logger.defaultLogError(e); - } catch (DatabaseException e) { - Logger.defaultLogError(e); + } catch (UnsupportedFlavorException|IOException|DatabaseException e) { + LOGGER.error("dragEnter failed", e); } - } dtde.acceptDrag(DnDConstants.ACTION_COPY); diff --git a/bundles/org.simantics.modeling/META-INF/MANIFEST.MF b/bundles/org.simantics.modeling/META-INF/MANIFEST.MF index 249d9ec7c..5245ed47e 100644 --- a/bundles/org.simantics.modeling/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.modeling/META-INF/MANIFEST.MF @@ -36,7 +36,8 @@ Require-Bundle: org.simantics.simulation;bundle-version="1.0.0", org.simantics.scenegraph.profile;bundle-version="1.0.0", org.simantics.scl.db;bundle-version="0.1.3", org.simantics.selectionview.ontology;bundle-version="1.2.0", - org.simantics.scl.ui;bundle-version="0.5.0" + org.simantics.scl.ui;bundle-version="0.5.0", + org.slf4j.api Export-Package: org.simantics.modeling, org.simantics.modeling.actions, org.simantics.modeling.adapters, diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/SCL.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/SCL.java index 555401327..bfa42b40e 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/SCL.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/SCL.java @@ -10,7 +10,6 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.jobs.IJobManager; import org.eclipse.core.runtime.jobs.Job; import org.simantics.DatabaseJob; -import org.simantics.Logger; import org.simantics.Simantics; import org.simantics.SimanticsPlatform; import org.simantics.SimanticsPlatform.OntologyRecoveryPolicy; @@ -24,8 +23,12 @@ import org.simantics.db.layer0.request.external.EclipsePreferencePrimitiveRead; import org.simantics.db.layer0.util.RemoverUtil; import org.simantics.db.layer0.util.SimanticsClipboard; import org.simantics.db.service.DebugSupport; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class SCL { + private static final Logger LOGGER = LoggerFactory.getLogger(SCL.class); + public static void killPlatformWrite(WriteGraph graph) throws DatabaseException { // Currently not supported. // Would be relatively easy to support the desired functionality. @@ -109,7 +112,7 @@ public class SCL { try { Thread.sleep(ms); } catch (InterruptedException e) { - Logger.defaultLogError(e); + LOGGER.warn("Sleep was interrupted.", e); } } diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/scl/SCLRealm.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/scl/SCLRealm.java index 99ac161a5..8ed8c3e0e 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/scl/SCLRealm.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/scl/SCLRealm.java @@ -1,7 +1,5 @@ package org.simantics.modeling.scl; -import gnu.trove.map.hash.THashMap; - import java.io.IOException; import java.util.Map; import java.util.concurrent.ExecutorService; @@ -11,7 +9,6 @@ import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; -import org.simantics.Logger; import org.simantics.databoard.Bindings; import org.simantics.databoard.binding.Binding; import org.simantics.databoard.binding.mutable.Variant; @@ -24,8 +21,14 @@ import org.simantics.scl.runtime.function.Function; import org.simantics.scl.runtime.tuple.Tuple0; import org.simantics.simulator.variable.NodeManager; import org.simantics.simulator.variable.Realm; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import gnu.trove.map.hash.THashMap; public class SCLRealm implements Realm { + private static final Logger LOGGER = LoggerFactory.getLogger(SCLRealm.class); + public static final String SCL = "scl"; THashMap contextTypes = new THashMap(); @@ -118,7 +121,7 @@ public class SCLRealm implements Realm { try { runnable.run(); } catch (Throwable t) { - Logger.defaultLogError(t); + LOGGER.error("Runnable failed in syncExec.", t); } finally { } return; @@ -132,7 +135,7 @@ public class SCLRealm implements Realm { try { runnable.run(); } catch (Throwable t) { - Logger.defaultLogError(t); + LOGGER.error("Runnable failed in syncExec.", t); } finally { executorThread = oldThread; endSyncExec.release(); @@ -146,7 +149,7 @@ public class SCLRealm implements Realm { try { runnable.run(); } catch (Throwable t) { - Logger.defaultLogError(t); + LOGGER.error("Runnable failed in asyncExec.", t); } finally { } return; diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/typicals/SyncTypicalTemplatesToInstances.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/typicals/SyncTypicalTemplatesToInstances.java index cd3260513..96a33393a 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/typicals/SyncTypicalTemplatesToInstances.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/typicals/SyncTypicalTemplatesToInstances.java @@ -24,7 +24,6 @@ import java.util.Map; import java.util.Set; import org.eclipse.core.runtime.IProgressMonitor; -import org.simantics.Logger; import org.simantics.Simantics; import org.simantics.databoard.Bindings; import org.simantics.db.ReadGraph; @@ -81,6 +80,8 @@ import org.simantics.utils.datastructures.MapSet; import org.simantics.utils.strings.AlphanumComparator; import org.simantics.utils.strings.EString; import org.simantics.utils.ui.ErrorLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; @@ -102,6 +103,7 @@ import gnu.trove.set.hash.THashSet; * @see TypicalSynchronizationMetadata */ public class SyncTypicalTemplatesToInstances extends WriteRequest { + private static final Logger LOGGER = LoggerFactory.getLogger(SyncTypicalTemplatesToInstances.class); /** * A constant used as the second argument to @@ -423,8 +425,7 @@ public class SyncTypicalTemplatesToInstances extends WriteRequest { syncInstance(graph, template, instance, templateElements); } } catch (Exception e) { - Logger.defaultLogError(e); - e.printStackTrace(); + LOGGER.error("Template synchronization failed.", e); } finally { this.temporaryDiagram.removeHint(DiagramModelHints.KEY_DIAGRAM_RESOURCE); } diff --git a/bundles/org.simantics.project/META-INF/MANIFEST.MF b/bundles/org.simantics.project/META-INF/MANIFEST.MF index ec287cffc..42e503aab 100644 --- a/bundles/org.simantics.project/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.project/META-INF/MANIFEST.MF @@ -33,12 +33,12 @@ Require-Bundle: org.simantics.db.layer0;bundle-version="[0.8.0,2.0.0)", org.eclipse.equinox.p2.touchpoint.natives;bundle-version="1.0.200", org.eclipse.equinox.p2.transport.ecf;bundle-version="1.0.0", org.simantics.graph.db;bundle-version="1.0.0", - org.apache.log4j;bundle-version="1.2.15", org.simantics.db.procore;bundle-version="1.1.0", org.eclipse.swt;bundle-version="3.6.0";resolution:=optional, org.eclipse.core.resources;bundle-version="3.6.0";resolution:=optional, org.simantics.graph.compiler;bundle-version="1.1.10", - org.simantics.ltk;bundle-version="1.1.10" + org.simantics.ltk;bundle-version="1.1.10", + org.slf4j.api Export-Package: org.eclipse.equinox.internal.p2.ui.query, org.eclipse.equinox.internal.provisional.p2.installer, org.simantics.project, diff --git a/bundles/org.simantics.project/src/org/simantics/project/management/ServerManager.java b/bundles/org.simantics.project/src/org/simantics/project/management/ServerManager.java index 56cf3254c..205706c48 100644 --- a/bundles/org.simantics.project/src/org/simantics/project/management/ServerManager.java +++ b/bundles/org.simantics.project/src/org/simantics/project/management/ServerManager.java @@ -22,7 +22,6 @@ import java.util.HashMap; import java.util.Map; import java.util.Properties; -import org.apache.log4j.Logger; import org.simantics.databoard.util.StreamUtil; import org.simantics.db.Driver; import org.simantics.db.Driver.Management; @@ -40,6 +39,8 @@ import org.simantics.db.service.XSupport; import org.simantics.graph.db.CoreInitialization; import org.simantics.layer0.DatabaseManagementResource; import org.simantics.layer0.Layer0; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Server Manager handles starting and pooling of ProCore server instances. @@ -47,7 +48,8 @@ import org.simantics.layer0.Layer0; * @author Toni Kalajainen */ public class ServerManager { - + private static final Logger LOGGER = LoggerFactory.getLogger(ServerManager.class); + /** Default properties with default user and password */ public static final Properties DEFAULT; @@ -81,8 +83,7 @@ public class ServerManager { */ public Session createDatabase(File databaseDirectory) throws DatabaseException { try { - Logger myLogger = Logger.getLogger(ServerManager.class); - myLogger.debug("Creating database to "+ databaseDirectory); + LOGGER.debug("Creating database to "+ databaseDirectory); Session session = null; ServerEx server1 = getServer(databaseDirectory); @@ -206,8 +207,7 @@ public class ServerManager { if (server.isActive()) server.stop(); } catch (DatabaseException e) { - Logger myLogger = Logger.getLogger(ServerManager.class); - myLogger.error(e); + LOGGER.error("Failed to stop database server.", e); } } servers.clear(); diff --git a/bundles/org.simantics.project/src/org/simantics/project/management/ServerManagerFactory.java b/bundles/org.simantics.project/src/org/simantics/project/management/ServerManagerFactory.java index 8957a2167..65190614c 100644 --- a/bundles/org.simantics.project/src/org/simantics/project/management/ServerManagerFactory.java +++ b/bundles/org.simantics.project/src/org/simantics/project/management/ServerManagerFactory.java @@ -22,19 +22,21 @@ import java.net.URLDecoder; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; -import org.apache.log4j.Logger; import org.simantics.db.DatabaseUserAgent; import org.simantics.db.Driver; import org.simantics.db.Manager; import org.simantics.db.exception.DatabaseException; -import org.simantics.utils.FileUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ServerManagerFactory { + private static final Logger LOGGER = LoggerFactory.getLogger(ServerManagerFactory.class); + public static ServerManager create(String databaseDriverId, String address) throws IOException, DatabaseException { Driver driver = Manager.getDriver(databaseDriverId); if (driver == null) throw new IllegalArgumentException("Database driver with ID " + databaseDriverId + " could not be found!"); - System.out.println("ServerManagerFactory.create called with id " + databaseDriverId + ", driver is " + driver.toString()); + LOGGER.info("ServerManagerFactory.create called with id {}, driver is {}.", databaseDriverId, driver); DatabaseUserAgent agent = Manager.getUserAgent(databaseDriverId); if (agent != null) driver.setDatabaseUserAgent(address, agent); @@ -166,7 +168,6 @@ public class ServerManagerFactory { * @throws IOException */ private static void extractZip(InputStream zipInput, File dst) throws IOException { - Logger myLogger = Logger.getLogger(FileUtils.class); byte[] buf = new byte[8192]; ZipInputStream zis = new ZipInputStream(zipInput); ZipEntry entry; @@ -175,7 +176,7 @@ public class ServerManagerFactory { while (entry != null) { // for each entry to be extracted String name = entry.getName(); - myLogger.debug("Extracting "+name); + LOGGER.debug("Extracting "+name); File file = new File(dst, name); if (entry.isDirectory()) diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/Expression.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/Expression.java index edf93841b..e01098c12 100755 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/Expression.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/Expression.java @@ -207,8 +207,6 @@ public abstract class Expression extends Symbol implements Typed { public abstract void collectFreeVariables(THashSet vars); public Expression simplify(SimplificationContext context) { - System.out.println("#############################"); - System.out.println(this); throw new InternalCompilerError(location, getClass().getSimpleName() + " does not support simplify method."); } diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/relations/TransitiveClosureRelation.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/relations/TransitiveClosureRelation.java index 26111e0b4..c9fa469d2 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/relations/TransitiveClosureRelation.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/relations/TransitiveClosureRelation.java @@ -67,13 +67,9 @@ public class TransitiveClosureRelation extends AbstractRelation implements Compo type = type.replace(getTypeVariables(), typeParameters); Expression continuation = context.getContinuation(); - System.out.println("continuation = " + continuation + " :: " + continuation.getType()); Variable set = new Variable("set", Types.apply(Types.con("MSet", "T"), type)); Variable f = new Variable("f", Types.functionE(type, Types.PROC, continuation.getType())); Variable innerSolved = new Variable("tcTemp", solved.getType()); - System.out.println("set :: " + set.getType()); - System.out.println("f :: " + f.getType()); - System.out.println("tcTemp :: " + innerSolved.getType()); QueryCompilationContext newContext = context.createSubcontext(new EApply( new EVariable(f), new EVariable(innerSolved) diff --git a/bundles/org.simantics.scl.runtime/META-INF/MANIFEST.MF b/bundles/org.simantics.scl.runtime/META-INF/MANIFEST.MF index 64d5ac63d..7274b0bf2 100755 --- a/bundles/org.simantics.scl.runtime/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.scl.runtime/META-INF/MANIFEST.MF @@ -21,4 +21,5 @@ Export-Package: org.simantics.scl.runtime, org.simantics.scl.runtime.xml Require-Bundle: org.junit;bundle-version="4.12.0";resolution:=optional, gnu.trove3;bundle-version="3.0.0", - org.simantics.databoard;bundle-version="0.6.5";visibility:=reexport + org.simantics.databoard;bundle-version="0.6.5";visibility:=reexport, + org.slf4j.api;bundle-version="1.7.20" diff --git a/bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/reporting/SCLReportingHandler.java b/bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/reporting/SCLReportingHandler.java index a53595646..91e71d652 100755 --- a/bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/reporting/SCLReportingHandler.java +++ b/bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/reporting/SCLReportingHandler.java @@ -1,5 +1,8 @@ package org.simantics.scl.runtime.reporting; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** *

An interface that is used to handle printing commands from SCL * such as Prelude.print. This interface is typically stored to @@ -11,6 +14,7 @@ package org.simantics.scl.runtime.reporting; * @author Hannu Niemistö */ public interface SCLReportingHandler { + public static final Logger LOGGER = LoggerFactory.getLogger(SCLReportingHandler.class); public static final String REPORTING_HANDLER = "reportingHandler"; public void print(String text); @@ -19,6 +23,34 @@ public interface SCLReportingHandler { public void didWork(double amount); public static final SCLReportingHandler DEFAULT = new AbstractSCLReportingHandler() { + @Override + public void print(String text) { + LOGGER.info(text); + } + + @Override + public void printError(String error) { + LOGGER.error(error); + } + }; + + public static final SCLReportingHandler DEFAULT_WITHOUT_ECHO = new AbstractSCLReportingHandler() { + @Override + public void print(String text) { + LOGGER.info(text); + } + + @Override + public void printError(String error) { + LOGGER.error(error); + } + + @Override + public void printCommand(String command) { + } + }; + + public static final SCLReportingHandler SYSOUT = new AbstractSCLReportingHandler() { @Override public void print(String text) { System.out.println(text); @@ -30,7 +62,7 @@ public interface SCLReportingHandler { } }; - public static final SCLReportingHandler DEFAULT_WITHOUT_ECHO = new AbstractSCLReportingHandler() { + public static final SCLReportingHandler SYSOUT_WITHOUT_ECHO = new AbstractSCLReportingHandler() { @Override public void print(String text) { System.out.println(text); diff --git a/bundles/org.simantics.selectionview/META-INF/MANIFEST.MF b/bundles/org.simantics.selectionview/META-INF/MANIFEST.MF index 606078e6c..1652bea8f 100644 --- a/bundles/org.simantics.selectionview/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.selectionview/META-INF/MANIFEST.MF @@ -21,7 +21,8 @@ Require-Bundle: org.eclipse.ui, org.simantics.views.ontology;bundle-version="1.0.0", org.simantics.browsing.ui.model;bundle-version="1.0.0", org.simantics.modeling;bundle-version="1.1.1", - org.simantics.scenegraph.ontology;bundle-version="1.0.0" + org.simantics.scenegraph.ontology;bundle-version="1.0.0", + org.slf4j.api Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy Export-Package: org.simantics.selectionview diff --git a/bundles/org.simantics.selectionview/src/org/simantics/selectionview/StandardSelectionProcessor.java b/bundles/org.simantics.selectionview/src/org/simantics/selectionview/StandardSelectionProcessor.java index 7b5cdf98c..ccf4eeb9f 100644 --- a/bundles/org.simantics.selectionview/src/org/simantics/selectionview/StandardSelectionProcessor.java +++ b/bundles/org.simantics.selectionview/src/org/simantics/selectionview/StandardSelectionProcessor.java @@ -6,7 +6,7 @@ import java.util.Collections; import java.util.HashSet; import java.util.Set; -import org.simantics.Logger; +import org.simantics.Simantics; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.common.request.PossibleIndexRoot; @@ -21,8 +21,11 @@ import org.simantics.db.layer0.variable.Variables; import org.simantics.layer0.Layer0; import org.simantics.ui.selection.WorkbenchSelectionUtils; import org.simantics.utils.ui.ISelectionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class StandardSelectionProcessor implements SelectionProcessor { + private static final Logger LOGGER = LoggerFactory.getLogger(StandardSelectionProcessor.class); private static Resource getIndexRoot(ReadGraph graph, Object selection) throws DatabaseException { @@ -113,10 +116,8 @@ public class StandardSelectionProcessor implements SelectionProcessor> { + private static final Logger LOGGER = LoggerFactory.getLogger(ConnectionPointMapOfResource.class); + public ConnectionPointMapOfResource(ReadGraph graph, Resource resource) throws DatabaseException { super(graph, resource); } @@ -49,7 +53,7 @@ public class ConnectionPointMapOfResource extends TransientResourceRead(predicates.size()); if (result.put(info.name, predicate) != null) - System.err.println(this + ": The database contains siblings with the same name " + info.name + " (resource=$" + resource.getResourceId() + ")."); + LOGGER.error("The database contains siblings with the same name " + info.name + " (resource=$" + resource.getResourceId() + ")."); } } diff --git a/bundles/org.simantics.ui/META-INF/MANIFEST.MF b/bundles/org.simantics.ui/META-INF/MANIFEST.MF index 73c65c06f..4b043cee1 100644 --- a/bundles/org.simantics.ui/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.ui/META-INF/MANIFEST.MF @@ -29,7 +29,8 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.e4.ui.workbench, org.eclipse.e4.ui.di, org.eclipse.e4.ui.bindings, - org.simantics.modeling.ontology;bundle-version="1.2.0" + org.simantics.modeling.ontology;bundle-version="1.2.0", + org.slf4j.api Bundle-ActivationPolicy: lazy Export-Package: org.simantics.ui, org.simantics.ui.colors, diff --git a/bundles/org.simantics.ui/src/org/simantics/ui/workbench/editor/GraphEditorAdapterDescriptor.java b/bundles/org.simantics.ui/src/org/simantics/ui/workbench/editor/GraphEditorAdapterDescriptor.java index 3ffa5b457..b5bb6191c 100644 --- a/bundles/org.simantics.ui/src/org/simantics/ui/workbench/editor/GraphEditorAdapterDescriptor.java +++ b/bundles/org.simantics.ui/src/org/simantics/ui/workbench/editor/GraphEditorAdapterDescriptor.java @@ -5,7 +5,6 @@ import java.util.Collection; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; -import org.simantics.Logger; import org.simantics.Simantics; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; @@ -19,9 +18,12 @@ import org.simantics.modeling.ModelingResources; import org.simantics.ui.utils.ResourceAdaptionUtils; import org.simantics.ui.workbench.ResourceEditorInput2; import org.simantics.utils.ui.workbench.WorkbenchUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class GraphEditorAdapterDescriptor implements EditorAdapterDescriptor { - + private static final Logger LOGGER = LoggerFactory.getLogger(GraphEditorAdapterDescriptor.class); + private final String editorId; private final String label; private final ImageDescriptor imageDescriptor; @@ -95,7 +97,7 @@ public class GraphEditorAdapterDescriptor implements EditorAdapterDescriptor { try { WorkbenchUtils.openEditor(editorId, new ResourceEditorInput2(editorId, r, model, rvi)); } catch (PartInitException e) { - Logger.defaultLogError(e); + LOGGER.error("Failed to open the graph editor", e); } } }); diff --git a/bundles/org.simantics/src/org/simantics/Logger.java b/bundles/org.simantics/src/org/simantics/Logger.java deleted file mode 100644 index 3001de3f6..000000000 --- a/bundles/org.simantics/src/org/simantics/Logger.java +++ /dev/null @@ -1,126 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics; - -import java.util.Properties; - -import org.simantics.internal.Activator; - - - -public class Logger { - public static final boolean ECHO = true; - public static final Properties defaultProperties = new Properties(); - static { - defaultProperties.put("log4j.rootCategory", "INFO, default"); - defaultProperties.put("log4j.appender.default", "org.apache.log4j.FileAppender"); - defaultProperties.put("log4j.appender.default.File", Activator.LOG_FILE_NAME); - defaultProperties.put("log4j.appender.default.append", "false"); - defaultProperties.put("log4j.appender.default.layout", "org.apache.log4j.PatternLayout"); - defaultProperties.put("log4j.appender.default.layout.ConversionPattern", "%d{ISO8601} %-6r [%15.15t] %-5p %30.30c - %m%n"); - } - private static LogManager defaultLogManager = new LogManager(defaultProperties); - private static final Logger defaultErrorLogger = new Logger(LogManager.class); - private org.apache.log4j.Logger logger; - Logger(Class clazz) { - logger = defaultLogManager.getLogger(clazz); - } - - /** - * Log a trace event. - * - * @param message message of the trace - * @param exception the exception, or null - */ - public void logTrace(String message, Throwable exception) { - // Errors are much more useful with a stack trace! - if (exception == null) { - exception = new RuntimeException(); - } - logger.trace(message, exception); - } - - /** - * Log an info event. - * - * @param message message of the info - * @param exception the exception, or null - */ - public void logInfo(String message, Throwable exception) { - // Errors are much more useful with a stack trace! - if (exception == null) { - exception = new RuntimeException(); - } - logger.info(message, exception); - } - - /** - * Log a warning event. - * - * @param message message of the warning - * @param exception the exception, or null - */ - public void logWarning(String message, Throwable exception) { - // Errors are much more useful with a stack trace! - if (exception == null) { - exception = new RuntimeException(); - } - logger.warn(message, exception); - } - - /** - * Log an error event. - * - * @param message message of the error - * @param exception the exception, or null - */ - public void logError(String message, Throwable exception) { - // Errors are much more useful with a stack trace! - if (exception == null) { - exception = new RuntimeException(); - } - logger.error(message, exception); - } - - public static Logger getDefault() { - return defaultErrorLogger; - } - - public static LogManager getDefaultLogManager() { - return defaultLogManager; - } - public static void defaultLogError(Throwable exception) { - getDefault().logError(exception.getLocalizedMessage(), exception); - if(ECHO) exception.printStackTrace(); - } - public static void defaultLogError(String message) { - getDefault().logError(message, null); - if(ECHO) - System.err.println(message); - } - public static void defaultLogError(String message, Throwable exception) { - getDefault().logError(message, exception); - if(ECHO) - System.err.println(message); - } - public static void defaultLogInfo(String message) { - getDefault().logInfo(message, null); - if(ECHO) - System.err.println(message); - } - public static void defaultLogTrace(String message) { - getDefault().logTrace(message, null); - if(ECHO) - System.err.println(message); - } - -} diff --git a/bundles/org.simantics/src/org/simantics/Simantics.java b/bundles/org.simantics/src/org/simantics/Simantics.java index 50110cb03..daa9e7e10 100644 --- a/bundles/org.simantics/src/org/simantics/Simantics.java +++ b/bundles/org.simantics/src/org/simantics/Simantics.java @@ -56,6 +56,8 @@ import org.simantics.utils.FileService; import org.simantics.utils.FileUtils; import org.simantics.utils.TempFiles; import org.simantics.utils.threads.ThreadUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * A facade for accessing basic Simantics platform services. Usable without a @@ -67,6 +69,7 @@ import org.simantics.utils.threads.ThreadUtils; * TODO: duplicate of org.simantics.db.layer0.util.Simantics, do something about this!! */ public class Simantics { + private static final Logger LOGGER = LoggerFactory.getLogger(Simantics.class); /** * Default database driver ID @@ -440,7 +443,7 @@ public class Simantics { try { IndexUtils.flushIndexCaches(progress, session); } catch (Exception e) { - Logger.defaultLogError(e); + LOGGER.error("Flushing index caches failed.", e); } } diff --git a/bundles/org.simantics/src/org/simantics/SimanticsPlatform.java b/bundles/org.simantics/src/org/simantics/SimanticsPlatform.java index d59fff9c2..09d632a3e 100644 --- a/bundles/org.simantics/src/org/simantics/SimanticsPlatform.java +++ b/bundles/org.simantics/src/org/simantics/SimanticsPlatform.java @@ -103,6 +103,7 @@ import org.simantics.project.management.WorkspaceUtil; import org.simantics.utils.FileUtils; import org.simantics.utils.datastructures.Pair; import org.simantics.utils.logging.TimeLogger; +import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** @@ -131,7 +132,7 @@ import org.slf4j.LoggerFactory; */ public class SimanticsPlatform implements LifecycleListener { - private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(SimanticsPlatform.class); + private static final Logger LOGGER = LoggerFactory.getLogger(SimanticsPlatform.class); /** * The policy is relevant when developing Simantics from Eclipse IDE. @@ -768,7 +769,7 @@ public class SimanticsPlatform implements LifecycleListener { }); TimeLogger.log("Flushed queries"); } catch (DatabaseException e) { - Logger.defaultLogError(e); + LOGGER.error("Flushing queries failed.", e); } boolean loadProject = true; try { @@ -809,7 +810,7 @@ public class SimanticsPlatform implements LifecycleListener { } } catch (DatabaseException e) { - Logger.defaultLogError(e); + LOGGER.error("Platform startup failed.", e); throw new PlatformException(e); } catch (ProjectException e) { boolean hasStackTrace = e.getStackTrace().length > 0; @@ -931,7 +932,7 @@ public class SimanticsPlatform implements LifecycleListener { try { Simantics.flushIndexCaches(progress.newChild(20), s); } catch (Throwable t) { - Logger.defaultLogError(t); + LOGGER.error("Failed to flush index caches.", t); } } @@ -972,7 +973,7 @@ public class SimanticsPlatform implements LifecycleListener { if (null != databasebManagement) databasebManagement.shutdown(); } catch (Throwable t) { - Logger.defaultLogError(t); + LOGGER.error("Database shutdown failed.", t); } progress.worked(10); @@ -980,7 +981,7 @@ public class SimanticsPlatform implements LifecycleListener { try { Simantics.clearTemporaryDirectory(); } catch (Throwable t) { - Logger.defaultLogError(t); + LOGGER.error("Failed to clear the temporary directory.", t); } progress.worked(10); if (null != platformException)