X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.interop.mapping%2Fsrc%2Forg%2Fsimantics%2Finterop%2Fmapping%2FLogger.java;fp=org.simantics.interop.mapping%2Fsrc%2Forg%2Fsimantics%2Finterop%2Fmapping%2FLogger.java;h=0000000000000000000000000000000000000000;hb=42badb1235a87eab88dc14caf579d1230c9d0560;hp=8ec1c07350b609afefcc12208ba4168eaae5733d;hpb=f353e9892e001df6d7d19a125c8309de511b57ec;p=simantics%2Finterop.git
diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/Logger.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/Logger.java
deleted file mode 100644
index 8ec1c07..0000000
--- a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/Logger.java
+++ /dev/null
@@ -1,133 +0,0 @@
-package org.simantics.interop.mapping;
-
-import java.util.Properties;
-
-import org.simantics.diagram.LogManager;
-
-public class Logger {
-
-
- public static final boolean ECHO = false;
- public static final boolean TRACE = false;
- 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", "mapping.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 %-5p - %m%n");
- //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 (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 (TRACE) {
- if (exception == null)
- exception = new RuntimeException();
- }
- logger.info(message, exception);
- }
-
- /**
- * Log an warning event.
- * @param message
- * @param exception
- */
- public void logWarning(String message, Throwable exception) {
- // Errors are much more useful with a stack trace!
- if (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 (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 setDefaultThreshold(String level) {
- getDefaultLogManager().setThreshold(level);
- }
-
- 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 defaultLogWarning(String message) {
- getDefault().logWarning(message, null);
- if(ECHO)
- System.err.println(message);
- }
-
- public static void defaultLogTrace(String message) {
- getDefault().logTrace(message, null);
- if(ECHO)
- System.err.println(message);
- }
-}