From: Tuukka Lehtonen Date: Fri, 14 Aug 2020 08:22:48 +0000 (+0300) Subject: Removed unnecessary dependencies on org.apache.log4j X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F79%2F4379%2F1;p=simantics%2Fplatform.git Removed unnecessary dependencies on org.apache.log4j gitlab #579 Change-Id: If0496edc82f46b3d49c30240bf0ba978324714de --- diff --git a/bundles/org.simantics.db.common/META-INF/MANIFEST.MF b/bundles/org.simantics.db.common/META-INF/MANIFEST.MF index 63b3e6bfc..a29371495 100644 --- a/bundles/org.simantics.db.common/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.db.common/META-INF/MANIFEST.MF @@ -7,7 +7,6 @@ Bundle-Vendor: VTT Technical Research Centre of Finland Bundle-RequiredExecutionEnvironment: JavaSE-11 Require-Bundle: org.simantics.db;bundle-version="1.1.0";visibility:=reexport, gnu.trove3;bundle-version="3.0.3", - org.apache.log4j;bundle-version="1.2.15", org.simantics.layer0;bundle-version="1.0.0";visibility:=reexport, org.simantics.graph;bundle-version="1.1.4", org.simantics.scl.reflection;bundle-version="1.0.0";visibility:=reexport, diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/utils/ErrorLogger.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/utils/ErrorLogger.java deleted file mode 100644 index 68ad37438..000000000 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/utils/ErrorLogger.java +++ /dev/null @@ -1,115 +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.db.common.utils; - -import java.util.Properties; - -import org.apache.log4j.Logger; - -/* - * - * @deprecated in favor of org.simantics.db.common.Logger. Will be removed in Simantics 1.2 - * - */ -@Deprecated -public class ErrorLogger { - public static final boolean ECHO = false; - public static final Properties defaultProperties = new Properties(); - static { - defaultProperties.put("log4j.rootCategory", "ERROR, default"); - defaultProperties.put("log4j.appender.default", "org.apache.log4j.FileAppender"); - defaultProperties.put("log4j.appender.default.File", "db-client-deprecated.log"); - defaultProperties.put("log4j.appender.default.append", "false"); - defaultProperties.put("log4j.appender.default.layout", "org.apache.log4j.PatternLayout"); - defaultProperties.put("log4j.appender.default.layout.ConversionPattern", "%-6r [%15.15t] %-5p %30.30c - %m%n"); - } - private static LogManager defaultLogManager = new LogManager(defaultProperties); - private static final ErrorLogger defaultErrorLogger = new ErrorLogger(LogManager.class); - private Logger logger; - ErrorLogger(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 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 ErrorLogger 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.db.common/src/org/simantics/db/common/utils/LogManager.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/utils/LogManager.java deleted file mode 100644 index 9abae439d..000000000 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/utils/LogManager.java +++ /dev/null @@ -1,151 +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.db.common.utils; - -import java.util.Properties; - -import org.apache.log4j.Hierarchy; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.apache.log4j.PropertyConfigurator; -import org.apache.log4j.spi.LoggerFactory; -import org.apache.log4j.spi.RootLogger; - -/** - * This class encapsulates a Log4J Hierarchy and centralizes all Logger access. - */ -public class LogManager { - - private Hierarchy hierarchy; - - /** - * Creates a new LogManager. Saves the log and state location. - * Creates a new Hierarchy and add a new EventListener to it. - * Configure the hierarchy with the properties passed. Add this object to - * the list of active log managers. - * - * @param properties log configuration properties - */ - public LogManager(Properties properties) { - this.hierarchy = new Hierarchy(new RootLogger(Level.DEBUG)); - new PropertyConfigurator().doConfigure(properties, this.hierarchy); - } - - /** - * Checks if this PluginLogManager is disabled for this level. - * - * @param level level value - * @return boolean true if it is disabled - */ - public boolean isDisabled(int level) { - return this.hierarchy.isDisabled(level); - } - - /** - * Enable logging for logging requests with level l or higher. By default - * all levels are enabled. - * - * @param level level object - */ - public void setThreshold(Level level) { - this.hierarchy.setThreshold(level); - } - - /** - * The string version of setThreshold(Level level) - * - * @param level level string - */ - public void setThreshold(String level) { - this.hierarchy.setThreshold(level); - } - - /** - * Get the repository-wide threshold. - * - * @return Level - */ - public Level getThreshold() { - return this.hierarchy.getThreshold(); - } - - /** - * Returns a new logger instance named as the first parameter using the - * default factory. If a logger of that name already exists, then it will be - * returned. Otherwise, a new logger will be instantiated and then linked - * with its existing ancestors as well as children. - * - * @param clazz the class to get the logger for - * @return Logger - */ - public Logger getLogger(Class clazz) { - return this.hierarchy.getLogger(clazz.getName()); - } - - /** - * Returns a new logger instance named as the first parameter using the - * default factory. If a logger of that name already exists, then it will be - * returned. Otherwise, a new logger will be instantiated and then linked - * with its existing ancestors as well as children. - * - * @param name logger name - * @return Logger - */ - public Logger getLogger(String name) { - return this.hierarchy.getLogger(name); - } - - /** - * The same as getLogger(String name) but using a factory instance instead - * of a default factory. - * - * @param name logger name - * @param factory factory instance - * @return Logger - */ - public Logger getLogger(String name, LoggerFactory factory) { - return this.hierarchy.getLogger(name, factory); - } - - /** - * Returns the root of this hierarchy. - * - * @return Logger - */ - public Logger getRootLogger() { - return this.hierarchy.getRootLogger(); - } - - /** - * Checks if this logger exists. - * - * @return Logger - */ - public Logger exists(String name) { - return this.hierarchy.exists(name); - } - - /** - * Disposes the logger hierarchy - */ - public void shutdown() { - this.hierarchy.shutdown(); - } - - /** - * Resets configuration values to its defaults. - */ - public void resetConfiguration() { - this.hierarchy.resetConfiguration(); - } - -} \ No newline at end of file diff --git a/bundles/org.simantics.db.layer0/META-INF/MANIFEST.MF b/bundles/org.simantics.db.layer0/META-INF/MANIFEST.MF index ac53847a3..17fc2ed8c 100644 --- a/bundles/org.simantics.db.layer0/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.db.layer0/META-INF/MANIFEST.MF @@ -9,7 +9,6 @@ Require-Bundle: gnu.trove3;bundle-version="3.0.3", org.simantics.databoard;bundle-version="0.6.2";visibility:=reexport, org.simantics.db.services;bundle-version="1.1.0";visibility:=reexport, org.simantics.db.management;bundle-version="1.1.0", - org.apache.log4j;bundle-version="1.2.15", org.apache.commons.io;bundle-version="1.4.0", org.simantics.layer0;bundle-version="1.0.0";visibility:=reexport, org.simantics.graph.db;bundle-version="1.1.5";visibility:=reexport, diff --git a/bundles/org.simantics.db.procore/META-INF/MANIFEST.MF b/bundles/org.simantics.db.procore/META-INF/MANIFEST.MF index d03b249ea..ac40619df 100644 --- a/bundles/org.simantics.db.procore/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.db.procore/META-INF/MANIFEST.MF @@ -4,8 +4,7 @@ Bundle-Name: ProCore Database Access Bundle-SymbolicName: org.simantics.db.procore Bundle-Version: 1.2.1.qualifier Bundle-Vendor: VTT Technical Research Centre of Finland -Require-Bundle: org.apache.log4j;visibility:=reexport, - org.simantics.db;bundle-version="0.8.0";visibility:=reexport, +Require-Bundle: org.simantics.db;bundle-version="0.8.0";visibility:=reexport, org.simantics.db.common;bundle-version="0.8.0";visibility:=reexport, gnu.trove3;bundle-version="3.0.0", org.simantics.db.impl;bundle-version="0.8.0", diff --git a/bundles/org.simantics.db.server/META-INF/MANIFEST.MF b/bundles/org.simantics.db.server/META-INF/MANIFEST.MF index 7e9cf890e..bd2c64b31 100644 --- a/bundles/org.simantics.db.server/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.db.server/META-INF/MANIFEST.MF @@ -11,8 +11,6 @@ Bundle-RequiredExecutionEnvironment: JavaSE-11 Import-Package: gnu.trove.impl.hash, gnu.trove.iterator, gnu.trove.map.hash, - org.apache.log4j, - org.apache.log4j.spi, org.eclipse.core.runtime, org.osgi.framework;version="1.3.0", org.simantics.db, diff --git a/bundles/org.simantics.diagram.profile/META-INF/MANIFEST.MF b/bundles/org.simantics.diagram.profile/META-INF/MANIFEST.MF index ffc1fac85..60816536a 100644 --- a/bundles/org.simantics.diagram.profile/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.diagram.profile/META-INF/MANIFEST.MF @@ -14,7 +14,8 @@ Require-Bundle: org.simantics.browsing.ui.swt;bundle-version="1.1.0", org.simantics.views.swt;bundle-version="1.0.0", org.simantics.views.swt.client;bundle-version="1.0.0", org.simantics.views.ontology;bundle-version="1.0.0", - org.simantics.selectionview;bundle-version="1.0.0" + org.simantics.selectionview;bundle-version="1.0.0", + org.slf4j.api Import-Package: org.simantics.views Bundle-Vendor: Semantum Oy Export-Package: org.simantics.diagram.profile.request diff --git a/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/CreateGroupAction.java b/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/CreateGroupAction.java index 58cd82b0e..cbe77333f 100644 --- a/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/CreateGroupAction.java +++ b/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/CreateGroupAction.java @@ -7,13 +7,16 @@ import org.simantics.db.WriteGraph; import org.simantics.db.common.request.WriteRequest; import org.simantics.db.common.utils.NameUtils; import org.simantics.db.exception.DatabaseException; -import org.simantics.diagram.Logger; import org.simantics.diagram.stubs.DiagramResource; import org.simantics.layer0.Layer0; import org.simantics.operation.Layer0X; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class CreateGroupAction extends ModelledActionImpl { + private static final Logger LOGGER = LoggerFactory.getLogger(CreateGroupAction.class); + public CreateGroupAction(Resource configuration) { super(configuration); } @@ -49,9 +52,7 @@ public class CreateGroupAction extends ModelledActionImpl { }); } catch (DatabaseException e) { - - Logger.defaultLogError(e); - + LOGGER.error("CreateGroupAction failed", e); } } diff --git a/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/CreateProfileAction.java b/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/CreateProfileAction.java index 656159abf..c0fdb11e3 100644 --- a/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/CreateProfileAction.java +++ b/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/CreateProfileAction.java @@ -8,12 +8,15 @@ import org.simantics.db.common.request.WriteRequest; import org.simantics.db.common.utils.NameUtils; import org.simantics.db.common.utils.OrderedSetUtils; import org.simantics.db.exception.DatabaseException; -import org.simantics.diagram.Logger; import org.simantics.diagram.stubs.DiagramResource; import org.simantics.layer0.Layer0; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class CreateProfileAction extends ModelledActionImpl { + private static final Logger LOGGER = LoggerFactory.getLogger(CreateProfileAction.class); + public CreateProfileAction(Resource configuration) { super(configuration); } @@ -51,9 +54,7 @@ public class CreateProfileAction extends ModelledActionImpl { }); } catch (DatabaseException e) { - - Logger.defaultLogError(e); - + LOGGER.error("CreateProfileAction failed", e); } } diff --git a/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/CreateStyleAction.java b/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/CreateStyleAction.java index de0734156..6cda70f2d 100644 --- a/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/CreateStyleAction.java +++ b/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/CreateStyleAction.java @@ -7,13 +7,16 @@ import org.simantics.db.WriteGraph; import org.simantics.db.common.request.WriteRequest; import org.simantics.db.common.utils.NameUtils; import org.simantics.db.exception.DatabaseException; -import org.simantics.diagram.Logger; import org.simantics.diagram.stubs.DiagramResource; import org.simantics.layer0.Layer0; import org.simantics.operation.Layer0X; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class CreateStyleAction extends ModelledActionImpl { + private static final Logger LOGGER = LoggerFactory.getLogger(CreateStyleAction.class); + public CreateStyleAction(Resource configuration) { super(configuration); } @@ -49,9 +52,7 @@ public class CreateStyleAction extends ModelledActionImpl { }); } catch (DatabaseException e) { - - Logger.defaultLogError(e); - + LOGGER.error("CreateStyleAction failed", e); } } diff --git a/bundles/org.simantics.diagram/META-INF/MANIFEST.MF b/bundles/org.simantics.diagram/META-INF/MANIFEST.MF index 56776f834..92e4d84ae 100644 --- a/bundles/org.simantics.diagram/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.diagram/META-INF/MANIFEST.MF @@ -18,7 +18,6 @@ Require-Bundle: org.simantics.utils.thread.swt, org.simantics.diagram.ontology;bundle-version="1.0.0";visibility:=reexport, org.simantics.structural.ontology;bundle-version="1.0.0", org.simantics.layer0.utils;bundle-version="[1.0.0,2.0.0)", - org.apache.log4j;bundle-version="1.2.15", org.simantics.threadlog;bundle-version="1.0.0";resolution:=optional, org.simantics.graph;bundle-version="1.1.5", org.simantics.graph.db;bundle-version="1.1.5", diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/LogManager.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/LogManager.java deleted file mode 100644 index a4e1eab87..000000000 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/LogManager.java +++ /dev/null @@ -1,151 +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.diagram; - -import java.util.Properties; - -import org.apache.log4j.Hierarchy; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.apache.log4j.PropertyConfigurator; -import org.apache.log4j.spi.LoggerFactory; -import org.apache.log4j.spi.RootLogger; - -/** - * This class encapsulates a Log4J Hierarchy and centralizes all Logger access. - */ -public class LogManager { - - private Hierarchy hierarchy; - - /** - * Creates a new LogManager. Saves the log and state location. - * Creates a new Hierarchy and add a new EventListener to it. - * Configure the hierarchy with the properties passed. Add this object to - * the list of active log managers. - * - * @param properties log configuration properties - */ - public LogManager(Properties properties) { - this.hierarchy = new Hierarchy(new RootLogger(Level.DEBUG)); - new PropertyConfigurator().doConfigure(properties, this.hierarchy); - } - - /** - * Checks if this PluginLogManager is disabled for this level. - * - * @param level level value - * @return boolean true if it is disabled - */ - public boolean isDisabled(int level) { - return this.hierarchy.isDisabled(level); - } - - /** - * Enable logging for logging requests with level l or higher. By default - * all levels are enabled. - * - * @param level level object - */ - public void setThreshold(Level level) { - this.hierarchy.setThreshold(level); - } - - /** - * The string version of setThreshold(Level level) - * - * @param level level string - */ - public void setThreshold(String level) { - this.hierarchy.setThreshold(level); - } - - /** - * Get the repository-wide threshold. - * - * @return Level - */ - public Level getThreshold() { - return this.hierarchy.getThreshold(); - } - - /** - * Returns a new logger instance named as the first parameter using the - * default factory. If a logger of that name already exists, then it will be - * returned. Otherwise, a new logger will be instantiated and then linked - * with its existing ancestors as well as children. - * - * @param clazz the class to get the logger for - * @return Logger - */ - public Logger getLogger(Class clazz) { - return this.hierarchy.getLogger(clazz.getName()); - } - - /** - * Returns a new logger instance named as the first parameter using the - * default factory. If a logger of that name already exists, then it will be - * returned. Otherwise, a new logger will be instantiated and then linked - * with its existing ancestors as well as children. - * - * @param name logger name - * @return Logger - */ - public Logger getLogger(String name) { - return this.hierarchy.getLogger(name); - } - - /** - * The same as getLogger(String name) but using a factory instance instead - * of a default factory. - * - * @param name logger name - * @param factory factory instance - * @return Logger - */ - public Logger getLogger(String name, LoggerFactory factory) { - return this.hierarchy.getLogger(name, factory); - } - - /** - * Returns the root of this hierarchy. - * - * @return Logger - */ - public Logger getRootLogger() { - return this.hierarchy.getRootLogger(); - } - - /** - * Checks if this logger exists. - * - * @return Logger - */ - public Logger exists(String name) { - return this.hierarchy.exists(name); - } - - /** - * Disposes the logger hierarchy - */ - public void shutdown() { - this.hierarchy.shutdown(); - } - - /** - * Resets configuration values to its defaults. - */ - public void resetConfiguration() { - this.hierarchy.resetConfiguration(); - } - -} \ No newline at end of file diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/Logger.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/Logger.java deleted file mode 100644 index ad93cb85b..000000000 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/Logger.java +++ /dev/null @@ -1,107 +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.diagram; - -import java.util.Properties; - -public class Logger { - public static final boolean ECHO = false; - public static final Properties defaultProperties = new Properties(); - static { - defaultProperties.put("log4j.rootCategory", "ERROR, default"); - defaultProperties.put("log4j.appender.default", "org.apache.log4j.FileAppender"); - defaultProperties.put("log4j.appender.default.File", "diagram.log"); - defaultProperties.put("log4j.appender.default.append", "false"); - defaultProperties.put("log4j.appender.default.layout", "org.apache.log4j.PatternLayout"); - defaultProperties.put("log4j.appender.default.layout.ConversionPattern", "%-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 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.diagram/src/org/simantics/diagram/handler/CopyPasteHandler.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/handler/CopyPasteHandler.java index 52217c3cf..de10603d3 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/handler/CopyPasteHandler.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/handler/CopyPasteHandler.java @@ -44,7 +44,6 @@ import org.simantics.db.layer0.util.SimanticsKeys; import org.simantics.db.layer0.variable.Variable; import org.simantics.db.layer0.variable.Variables; import org.simantics.db.request.Read; -import org.simantics.diagram.Logger; import org.simantics.diagram.content.Change; import org.simantics.diagram.content.ConnectionUtil; import org.simantics.diagram.content.DiagramContentChanges; @@ -114,6 +113,8 @@ import org.simantics.utils.threads.SWTThread; import org.simantics.utils.threads.ThreadUtils; import org.simantics.utils.ui.ErrorLogger; import org.simantics.utils.ui.SWTUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * CopyPasteHandler is a canvas handler for Commands.CUT, Commands.COPY and @@ -141,6 +142,8 @@ import org.simantics.utils.ui.SWTUtils; */ public class CopyPasteHandler extends AbstractDiagramParticipant { + private static final Logger LOGGER = LoggerFactory.getLogger(CopyPasteHandler.class); + public static final Key KEY_CUT_SELECTION_FRAME_COLOR = new KeyOf(Color.class, "CUT_SELECTION_FRAME_COLOR"); public static final Key KEY_CUT_SELECTION_CONTENT_COLOR = new KeyOf(Color.class, "CUT_SELECTION_CONTENT_COLOR"); public static final Key KEY_COPIED_SELECTION_FRAME_COLOR = new KeyOf(Color.class, "COPY_SELECTION_FRAME_COLOR"); @@ -1294,7 +1297,7 @@ public class CopyPasteHandler extends AbstractDiagramParticipant { }); } } catch (DatabaseException e1) { - Logger.defaultLogError(e1); + LOGGER.error("Monitor paste failed", e1); } } return true; diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/handler/e4/CopyPasteHandler.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/handler/e4/CopyPasteHandler.java index 761494127..7f709c709 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/handler/e4/CopyPasteHandler.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/handler/e4/CopyPasteHandler.java @@ -44,7 +44,6 @@ import org.simantics.db.layer0.util.SimanticsKeys; import org.simantics.db.layer0.variable.Variable; import org.simantics.db.layer0.variable.Variables; import org.simantics.db.request.Read; -import org.simantics.diagram.Logger; import org.simantics.diagram.content.Change; import org.simantics.diagram.content.ConnectionUtil; import org.simantics.diagram.content.DiagramContentChanges; @@ -125,6 +124,8 @@ import org.simantics.utils.threads.SWTThread; import org.simantics.utils.threads.ThreadUtils; import org.simantics.utils.ui.ErrorLogger; import org.simantics.utils.ui.SWTUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * CopyPasteHandler is a canvas handler for Commands.CUT, Commands.COPY and @@ -152,6 +153,8 @@ import org.simantics.utils.ui.SWTUtils; */ public class CopyPasteHandler extends AbstractDiagramParticipant { + private static final Logger LOGGER = LoggerFactory.getLogger(CopyPasteHandler.class); + public static final Key KEY_CUT_SELECTION_FRAME_COLOR = new KeyOf(Color.class, "CUT_SELECTION_FRAME_COLOR"); public static final Key KEY_CUT_SELECTION_CONTENT_COLOR = new KeyOf(Color.class, "CUT_SELECTION_CONTENT_COLOR"); public static final Key KEY_COPIED_SELECTION_FRAME_COLOR = new KeyOf(Color.class, "COPY_SELECTION_FRAME_COLOR"); @@ -1291,7 +1294,7 @@ public class CopyPasteHandler extends AbstractDiagramParticipant { }); } } catch (DatabaseException e1) { - Logger.defaultLogError(e1); + LOGGER.error("Monitor paste failed", e1); } } return true; diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/PopulateSelectionDropParticipant.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/PopulateSelectionDropParticipant.java index 3e1140a07..0731bd90d 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/PopulateSelectionDropParticipant.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/PopulateSelectionDropParticipant.java @@ -24,10 +24,8 @@ import java.util.List; import org.eclipse.jface.viewers.IStructuredSelection; import org.simantics.db.Session; import org.simantics.db.exception.DatabaseException; -import org.simantics.diagram.Logger; import org.simantics.diagram.adapter.GraphToDiagramSynchronizer; import org.simantics.g2d.diagram.DiagramHints; -import org.simantics.g2d.diagram.DiagramMutator; import org.simantics.g2d.diagram.DiagramUtils; import org.simantics.g2d.diagram.IDiagram; import org.simantics.g2d.diagram.participant.AbstractDiagramParticipant; @@ -42,11 +40,14 @@ import org.simantics.g2d.element.IElement; import org.simantics.scenegraph.g2d.snap.ISnapAdvisor; import org.simantics.ui.dnd.LocalObjectTransfer; import org.simantics.ui.dnd.LocalObjectTransferable; -import org.simantics.utils.datastructures.Callback; import org.simantics.utils.logging.TimeLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; abstract public class PopulateSelectionDropParticipant extends AbstractDiagramParticipant implements IDropTargetParticipant { + private static final Logger LOGGER = LoggerFactory.getLogger(PopulateSelectionDropParticipant.class); + public abstract List getElements(Session session, IStructuredSelection selection) throws DatabaseException; protected GraphToDiagramSynchronizer synchronizer; @@ -96,12 +97,8 @@ abstract public class PopulateSelectionDropParticipant extends AbstractDiagramPa } - } catch (UnsupportedFlavorException e) { - Logger.defaultLogError(e); - } catch (IOException e) { - Logger.defaultLogError(e); - } catch (DatabaseException e) { - Logger.defaultLogError(e); + } catch (DatabaseException | IOException | UnsupportedFlavorException e) { + LOGGER.error("Unexpected failure", e); } } diff --git a/bundles/org.simantics.fileimport/META-INF/MANIFEST.MF b/bundles/org.simantics.fileimport/META-INF/MANIFEST.MF index 57c7e90ba..7adcb430e 100644 --- a/bundles/org.simantics.fileimport/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.fileimport/META-INF/MANIFEST.MF @@ -5,7 +5,6 @@ Bundle-SymbolicName: org.simantics.fileimport;singleton:=true Bundle-Version: 1.0.0.qualifier Bundle-Activator: org.simantics.fileimport.Activator Require-Bundle: org.eclipse.core.runtime, - org.apache.log4j, org.simantics.db, org.simantics, org.simantics.graphfile;bundle-version="0.1.0", diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DiagramViewerSelectionProvider.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DiagramViewerSelectionProvider.java index b7ea5ac78..d9d14c37e 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DiagramViewerSelectionProvider.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DiagramViewerSelectionProvider.java @@ -17,7 +17,6 @@ import org.simantics.db.layer0.SelectionHints; import org.simantics.db.layer0.request.PossibleModel; import org.simantics.db.layer0.variable.Variable; import org.simantics.db.layer0.variable.Variables; -import org.simantics.diagram.Logger; import org.simantics.diagram.flag.FlagUtil; import org.simantics.diagram.stubs.DiagramResource; import org.simantics.diagram.ui.DiagramModelHints; @@ -36,6 +35,8 @@ import org.simantics.ui.selection.WorkbenchSelectionContentType; import org.simantics.utils.DataContainer; import org.simantics.utils.threads.IThreadWorkQueue; import org.simantics.utils.ui.ErrorLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Antti Villberg @@ -44,6 +45,8 @@ public class DiagramViewerSelectionProvider extends WorkbenchSelectionProvider { protected static class SelectionElement extends AdaptableHintContext { + private static final Logger LOGGER = LoggerFactory.getLogger(SelectionElement.class); + final public Resource runtime; final public Resource element; @@ -108,7 +111,7 @@ public class DiagramViewerSelectionProvider extends WorkbenchSelectionProvider { } }); } catch (DatabaseException e) { - Logger.defaultLogError(e); + LOGGER.error("WorkbenchSelectionElement.getContent failed for type AnyVariable", e); } } else if(contentType instanceof ParentVariable) { @@ -117,10 +120,7 @@ public class DiagramViewerSelectionProvider extends WorkbenchSelectionProvider { return (T) type.processor.sync(new ResourceRead2(runtime, element) { @Override public Variable perform(ReadGraph graph) throws DatabaseException { - DiagramResource DIA = DiagramResource.getInstance(graph); - ModelingResources MOD = ModelingResources.getInstance(graph); - Layer0 L0 = Layer0.getInstance(graph); String uri = graph.getPossibleRelatedValue(resource, DIA.RuntimeDiagram_HasVariable); if (uri == null) @@ -134,7 +134,7 @@ public class DiagramViewerSelectionProvider extends WorkbenchSelectionProvider { } }); } catch (DatabaseException e) { - Logger.defaultLogError(e); + LOGGER.error("WorkbenchSelectionElement.getContent failed for type ParentVariable", e); } } diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/e4/PopulateElementDropParticipant.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/e4/PopulateElementDropParticipant.java index ac9413064..4e7ac0ab8 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/e4/PopulateElementDropParticipant.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/e4/PopulateElementDropParticipant.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * Copyright (c) 2007, 2020 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 @@ -45,7 +45,6 @@ import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.request.IsLinkedTo; import org.simantics.db.layer0.util.Layer0Utils; import org.simantics.db.service.SerialisationSupport; -import org.simantics.diagram.Logger; import org.simantics.diagram.adapter.GraphToDiagramSynchronizer; import org.simantics.diagram.content.Change; import org.simantics.diagram.content.DiagramContentChanges; @@ -83,12 +82,16 @@ import org.simantics.ui.dnd.LocalObjectTransferable; import org.simantics.ui.selection.WorkbenchSelectionElement; import org.simantics.ui.workbench.e4.E4WorkbenchUtils; import org.simantics.utils.logging.TimeLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This participant populates Elements from ElementClass-resources drops */ public class PopulateElementDropParticipant extends AbstractDiagramParticipant implements IDropTargetParticipant { + private static final Logger LOGGER = LoggerFactory.getLogger(PopulateElementDropParticipant.class); + @Dependency PickContext pickContext; @Dependency TransformUtil transformUtil; @@ -321,7 +324,7 @@ public class PopulateElementDropParticipant extends AbstractDiagramParticipant i }); } catch (DatabaseException e) { - Logger.defaultLogError(e); + LOGGER.error("symbolDropHandler invocation failed", e); } return; diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLAction.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLAction.java index 47c7d3466..ba7e7117f 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLAction.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLAction.java @@ -8,11 +8,14 @@ import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.adapter.ActionFactory; import org.simantics.db.layer0.variable.Variable; import org.simantics.db.layer0.variable.Variables; -import org.simantics.diagram.Logger; import org.simantics.scl.runtime.function.Function1; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class SCLAction implements ActionFactory { + private static final Logger LOGGER = LoggerFactory.getLogger(SCLAction.class); + final private Resource rule; public SCLAction(ReadGraph graph, Resource rule) throws DatabaseException { @@ -52,7 +55,7 @@ public class SCLAction implements ActionFactory { Function1 function = Simantics.getSession().syncRequest(new RuleFunctionRequest(rule)); function.apply(resource); } catch (DatabaseException e) { - Logger.defaultLogError(e); + LOGGER.error("SCLActionRunnable failed to request/apply RuleFunction {}", rule, e); } } diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLDropAction.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLDropAction.java index 74b19a214..f1d385545 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLDropAction.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLDropAction.java @@ -8,11 +8,14 @@ import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.adapter.DropActionFactory; import org.simantics.db.layer0.variable.Variable; import org.simantics.db.layer0.variable.Variables; -import org.simantics.diagram.Logger; import org.simantics.scl.runtime.function.Function3; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class SCLDropAction implements DropActionFactory { + private static final Logger LOGGER = LoggerFactory.getLogger(SCLDropAction.class); + final private Resource rule; public SCLDropAction(ReadGraph graph, Resource rule) throws DatabaseException { @@ -55,7 +58,7 @@ public class SCLDropAction implements DropActionFactory { Function3 function = Simantics.getSession().syncRequest(new RuleFunctionRequest(rule)); function.apply(target, source, operation); } catch (DatabaseException e) { - Logger.defaultLogError(e); + LOGGER.error("SCLDropActionRunnable failed to request/apply RuleFunction {}", rule, e); } } diff --git a/bundles/org.simantics.spreadsheet.common/META-INF/MANIFEST.MF b/bundles/org.simantics.spreadsheet.common/META-INF/MANIFEST.MF index b019ac5cc..3e2330afe 100644 --- a/bundles/org.simantics.spreadsheet.common/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.spreadsheet.common/META-INF/MANIFEST.MF @@ -6,7 +6,6 @@ Bundle-Version: 1.1.0.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-11 Require-Bundle: org.simantics.utils.datastructures;bundle-version="1.0.0", org.simantics.utils.ui;bundle-version="1.0.0", - org.apache.log4j;bundle-version="1.2.15", org.simantics.spreadsheet;bundle-version="1.1.0", org.simantics.db.layer0;bundle-version="1.1.0", org.simantics.scl.runtime;bundle-version="0.1.2", diff --git a/bundles/org.simantics/META-INF/MANIFEST.MF b/bundles/org.simantics/META-INF/MANIFEST.MF index 604255263..4829d00c5 100644 --- a/bundles/org.simantics/META-INF/MANIFEST.MF +++ b/bundles/org.simantics/META-INF/MANIFEST.MF @@ -11,7 +11,6 @@ Require-Bundle: org.eclipse.core.runtime;visibility:=reexport, org.simantics.project;bundle-version="1.0.1";visibility:=reexport, org.simantics.graph.db;bundle-version="1.1.5", org.eclipse.equinox.p2.metadata;bundle-version="2.0.0", - org.apache.log4j;bundle-version="1.2.15", org.simantics.layer0.utils;bundle-version="1.1.0", org.simantics.application;bundle-version="1.1.0", org.simantics.db.indexing;bundle-version="1.1.0", diff --git a/bundles/org.simantics/src/org/simantics/LogManager.java b/bundles/org.simantics/src/org/simantics/LogManager.java deleted file mode 100644 index 4274002c6..000000000 --- a/bundles/org.simantics/src/org/simantics/LogManager.java +++ /dev/null @@ -1,151 +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.apache.log4j.Hierarchy; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.apache.log4j.PropertyConfigurator; -import org.apache.log4j.spi.LoggerFactory; -import org.apache.log4j.spi.RootLogger; - -/** - * This class encapsulates a Log4J Hierarchy and centralizes all Logger access. - */ -public class LogManager { - - private Hierarchy hierarchy; - - /** - * Creates a new LogManager. Saves the log and state location. - * Creates a new Hierarchy and add a new EventListener to it. - * Configure the hierarchy with the properties passed. Add this object to - * the list of active log managers. - * - * @param properties log configuration properties - */ - public LogManager(Properties properties) { - this.hierarchy = new Hierarchy(new RootLogger(Level.DEBUG)); - new PropertyConfigurator().doConfigure(properties, this.hierarchy); - } - - /** - * Checks if this PluginLogManager is disabled for this level. - * - * @param level level value - * @return boolean true if it is disabled - */ - public boolean isDisabled(int level) { - return this.hierarchy.isDisabled(level); - } - - /** - * Enable logging for logging requests with level l or higher. By default - * all levels are enabled. - * - * @param level level object - */ - public void setThreshold(Level level) { - this.hierarchy.setThreshold(level); - } - - /** - * The string version of setThreshold(Level level) - * - * @param level level string - */ - public void setThreshold(String level) { - this.hierarchy.setThreshold(level); - } - - /** - * Get the repository-wide threshold. - * - * @return Level - */ - public Level getThreshold() { - return this.hierarchy.getThreshold(); - } - - /** - * Returns a new logger instance named as the first parameter using the - * default factory. If a logger of that name already exists, then it will be - * returned. Otherwise, a new logger will be instantiated and then linked - * with its existing ancestors as well as children. - * - * @param clazz the class to get the logger for - * @return Logger - */ - public Logger getLogger(Class clazz) { - return this.hierarchy.getLogger(clazz.getName()); - } - - /** - * Returns a new logger instance named as the first parameter using the - * default factory. If a logger of that name already exists, then it will be - * returned. Otherwise, a new logger will be instantiated and then linked - * with its existing ancestors as well as children. - * - * @param name logger name - * @return Logger - */ - public Logger getLogger(String name) { - return this.hierarchy.getLogger(name); - } - - /** - * The same as getLogger(String name) but using a factory instance instead - * of a default factory. - * - * @param name logger name - * @param factory factory instance - * @return Logger - */ - public Logger getLogger(String name, LoggerFactory factory) { - return this.hierarchy.getLogger(name, factory); - } - - /** - * Returns the root of this hierarchy. - * - * @return Logger - */ - public Logger getRootLogger() { - return this.hierarchy.getRootLogger(); - } - - /** - * Checks if this logger exists. - * - * @return Logger - */ - public Logger exists(String name) { - return this.hierarchy.exists(name); - } - - /** - * Disposes the logger hierarchy - */ - public void shutdown() { - this.hierarchy.shutdown(); - } - - /** - * Resets configuration values to its defaults. - */ - public void resetConfiguration() { - this.hierarchy.resetConfiguration(); - } - -} \ No newline at end of file diff --git a/features/org.simantics.rcp.feature/feature.xml b/features/org.simantics.rcp.feature/feature.xml index 910e199de..54dd72372 100644 --- a/features/org.simantics.rcp.feature/feature.xml +++ b/features/org.simantics.rcp.feature/feature.xml @@ -479,13 +479,6 @@ This Agreement is governed by the laws of the State of New York and the intellec version="0.0.0" unpack="false"/> - - + + diff --git a/tests/org.simantics.db.tests/META-INF/MANIFEST.MF b/tests/org.simantics.db.tests/META-INF/MANIFEST.MF index 71a1b9653..1d2330566 100644 --- a/tests/org.simantics.db.tests/META-INF/MANIFEST.MF +++ b/tests/org.simantics.db.tests/META-INF/MANIFEST.MF @@ -13,7 +13,6 @@ Require-Bundle: org.eclipse.core.runtime, org.simantics.db.management;bundle-version="0.8.0", gnu.trove3;bundle-version="3.0.3", org.simantics.fastlz;bundle-version="1.0.0", - org.apache.log4j;bundle-version="1.2.15", org.simantics.db.impl;bundle-version="0.8.0", org.simantics.db.layer0;bundle-version="0.8.0", org.simantics.project;bundle-version="1.0.1", diff --git a/tests/org.simantics.db.tests/build-installer.xml b/tests/org.simantics.db.tests/build-installer.xml index 05804fb84..80b7f7b9d 100644 --- a/tests/org.simantics.db.tests/build-installer.xml +++ b/tests/org.simantics.db.tests/build-installer.xml @@ -21,12 +21,11 @@ - - - + + @@ -35,10 +34,6 @@ - - - - diff --git a/tests/org.simantics.db.tests/build.xml b/tests/org.simantics.db.tests/build.xml index da0a86faa..4c6a1daf9 100644 --- a/tests/org.simantics.db.tests/build.xml +++ b/tests/org.simantics.db.tests/build.xml @@ -135,7 +135,6 @@ -