+++ /dev/null
-package org.simantics.interop.mapping;\r
-\r
-import java.util.Properties;\r
-\r
-import org.simantics.diagram.LogManager;\r
-\r
-public class Logger {\r
- \r
- \r
- public static final boolean ECHO = false;\r
- public static final boolean TRACE = false;\r
- public static final Properties defaultProperties = new Properties();\r
- static {\r
- defaultProperties.put("log4j.rootCategory", "INFO, default");\r
- defaultProperties.put("log4j.appender.default", "org.apache.log4j.FileAppender");\r
- defaultProperties.put("log4j.appender.default.File", "mapping.log");\r
- defaultProperties.put("log4j.appender.default.append", "false");\r
- defaultProperties.put("log4j.appender.default.layout", "org.apache.log4j.PatternLayout");\r
- defaultProperties.put("log4j.appender.default.layout.ConversionPattern", "%-6r %-5p - %m%n");\r
- //defaultProperties.put("log4j.appender.default.layout.ConversionPattern", "%-6r [%15.15t] %-5p %30.30c - %m%n");\r
- }\r
- private static LogManager defaultLogManager = new LogManager(defaultProperties);\r
- private static final Logger defaultErrorLogger = new Logger(LogManager.class);\r
- private org.apache.log4j.Logger logger;\r
- \r
- Logger(Class<?> clazz) {\r
- logger = defaultLogManager.getLogger(clazz);\r
- }\r
-\r
- /**\r
- * Log a trace event.\r
- * \r
- * @param message message of the trace\r
- * @param exception the exception, or <code>null</code>\r
- */\r
- public void logTrace(String message, Throwable exception) {\r
- // Errors are much more useful with a stack trace!\r
- if (TRACE) {\r
- if (exception == null)\r
- exception = new RuntimeException();\r
- }\r
- logger.trace(message, exception);\r
- }\r
-\r
- /**\r
- * Log an info event.\r
- * \r
- * @param message message of the info\r
- * @param exception the exception, or <code>null</code>\r
- */\r
- public void logInfo(String message, Throwable exception) {\r
- // Errors are much more useful with a stack trace!\r
- if (TRACE) {\r
- if (exception == null)\r
- exception = new RuntimeException();\r
- }\r
- logger.info(message, exception);\r
- }\r
- \r
- /**\r
- * Log an warning event.\r
- * @param message\r
- * @param exception\r
- */\r
- public void logWarning(String message, Throwable exception) {\r
- // Errors are much more useful with a stack trace!\r
- if (TRACE) {\r
- if (exception == null)\r
- exception = new RuntimeException();\r
- }\r
- logger.warn(message, exception);\r
- }\r
- \r
-\r
- /**\r
- * Log an error event.\r
- * \r
- * @param message message of the error\r
- * @param exception the exception, or <code>null</code>\r
- */\r
- public void logError(String message, Throwable exception) {\r
- // Errors are much more useful with a stack trace!\r
- if (TRACE) {\r
- if (exception == null)\r
- exception = new RuntimeException();\r
- }\r
- logger.error(message, exception);\r
- }\r
-\r
- public static Logger getDefault() {\r
- return defaultErrorLogger;\r
- }\r
- \r
- public static LogManager getDefaultLogManager() {\r
- return defaultLogManager;\r
- }\r
- \r
- public static void setDefaultThreshold(String level) {\r
- getDefaultLogManager().setThreshold(level);\r
- }\r
- \r
- public static void defaultLogError(Throwable exception) {\r
- getDefault().logError(exception.getLocalizedMessage(), exception);\r
- if(ECHO) exception.printStackTrace();\r
- }\r
- public static void defaultLogError(String message) {\r
- getDefault().logError(message, null);\r
- if(ECHO)\r
- System.err.println(message);\r
- }\r
- public static void defaultLogError(String message, Throwable exception) {\r
- getDefault().logError(message, exception);\r
- if(ECHO)\r
- System.err.println(message);\r
- }\r
- public static void defaultLogInfo(String message) {\r
- getDefault().logInfo(message, null);\r
- if(ECHO)\r
- System.err.println(message);\r
- }\r
- \r
- public static void defaultLogWarning(String message) {\r
- getDefault().logWarning(message, null);\r
- if(ECHO)\r
- System.err.println(message);\r
- }\r
- \r
- public static void defaultLogTrace(String message) {\r
- getDefault().logTrace(message, null);\r
- if(ECHO)\r
- System.err.println(message);\r
- }\r
-}\r
import org.simantics.ui.jobs.SessionGarbageCollectorJob;\r
import org.simantics.utils.datastructures.MapList;\r
import org.simantics.utils.datastructures.Pair;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
\r
/**\r
* \r
*\r
*/\r
public class Mapper {\r
- \r
+\r
+ private static final Logger LOGGER = LoggerFactory.getLogger(Mapper.class);\r
+\r
public static final boolean USE_SPLIT_TRANSACTIONS = false; // Split transactions\r
public static int OBJECTS_PER_TRANSACTION = 5000; // number of objects handled per transaction (split mode) \r
private static boolean SLEEP_BETWEEN_WRITES = false; // sleep between transactions (split mode) \r
\r
for (Pair<ConnectionIdentificationRule, ConnectionGenerationRule> r : connectionRules) {\r
if (r.first.mathces(g, node, link.to(), link)) {\r
- Logger.defaultLogInfo("Connecting " + getName(g, node.getData()) + " to " + getName(g, link.to().getData()) + " " + link.getName() + "/"+link.getInverseName());\r
+ LOGGER.info("Connecting " + getName(g, node.getData()) + " to " + getName(g, link.to().getData()) + " " + link.getName() + "/"+link.getInverseName());\r
r.second.generate(g, node, link.to(), link);\r
break;\r
}\r
import java.util.List;\r
import java.util.Set;\r
\r
-import org.simantics.interop.mapping.Logger;\r
import org.simantics.utils.datastructures.hints.HintContext;\r
+import org.slf4j.Logger;\r
\r
\r
/**\r
* @param <T>\r
*/\r
public class GraphNode<T> extends HintContext {\r
+ \r
+ private static final Logger LOGGER = org.slf4j.LoggerFactory.getLogger(GraphNode.class);\r
+ \r
protected T data;\r
private List<Link<T>> nodes = new ArrayList<Link<T>>();\r
\r
*/\r
public Link<T> addLink(String relationName, String inverseRelationName,GraphNode<T> node) {\r
_checkDisposed();\r
- Logger.defaultLogInfo("Node link " + data + " " + node.data + " " + relationName + " " + inverseRelationName +"\n");\r
+ LOGGER.info("Node link " + data + " " + node.data + " " + relationName + " " + inverseRelationName +"\n");\r
if(containsLink(relationName, node) && node.containsLink(inverseRelationName, this)) {\r
- Logger.defaultLogWarning("Node " + getData() + " has already given child " + node.getData() + " ,with name " + relationName + " / " + inverseRelationName);\r
+ LOGGER.warn("Node " + getData() + " has already given child " + node.getData() + " ,with name " + relationName + " / " + inverseRelationName);\r
return null;\r
}\r
Link<T> rel = _addLink(relationName,node);\r
public Link<T> addLink(String relationName,GraphNode<T> node) {\r
_checkDisposed();\r
if(containsLink(relationName, node)) {\r
- Logger.defaultLogWarning("Node " + getData() + " has already given child " + node.getData() + " ,with name " + relationName );\r
+ LOGGER.warn("Node " + getData() + " has already given child " + node.getData() + " ,with name " + relationName );\r
return null;\r
}\r
Link<T> rel = _addLink(relationName,node);\r
public Link<T> addLink(Link<T> link ,GraphNode<T> node) {\r
_checkDisposed();\r
if(containsLink(link.getName(), node) && node.containsLink(link.getInverseName(), this)) {\r
- Logger.defaultLogWarning("Node " + getData() + " has already given child " + node.getData() + " ,with name " + link.getName() + " / " + link.getInverseName());\r
+ LOGGER.warn("Node " + getData() + " has already given child " + node.getData() + " ,with name " + link.getName() + " / " + link.getInverseName());\r
return null;\r
}\r
Link<T> rel = _addLink(link.getName(),node);\r
public void destroy() {\r
if (disposed)\r
return;\r
- Logger.defaultLogInfo("Node destroy " + data + " " + this);\r
+ LOGGER.info("Node destroy " + data + " " + this);\r
Collection<Link<T>> coll = new ArrayList<Link<T>>();\r
coll.addAll(nodes);\r
nodes.clear();\r
if (disposed)\r
return;\r
// FIXME: link.to may be *this.\r
- Logger.defaultLogInfo("Node remove " + data + " " + this);\r
+ LOGGER.info("Node remove " + data + " " + this);\r
if (nodes.size() == 1) {\r
Link<T> link = nodes.get(0);\r
link.to().removeLink(link.getInverseName(), link.getName(), this);\r
\r
protected void _checkDisposed() {\r
if (disposed) {\r
- Logger.defaultLogError("Remove Node, disposed " + this);\r
+ LOGGER.error("Remove Node, disposed " + this);\r
throw new RuntimeException("Node " + this + " is disposed.");\r
}\r
}\r