]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/ErrorLogger.java
Fix ErrorLogger e.printStackTrace() calls to utilize Logger
[simantics/platform.git] / bundles / org.simantics.utils.ui / src / org / simantics / utils / ui / ErrorLogger.java
index 62fe87bad534adb89bc987ee5d196051b33e6d81..c8c49d17dcd816cf9f71248614c9508473302790 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * Copyright (c) 2007, 2018 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
@@ -15,17 +15,18 @@ import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Plugin;
 import org.eclipse.core.runtime.Status;
 import org.simantics.utils.ui.internal.Activator;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * ErrorLogger sends error messages to "Error log" view.
  * 
  * @author Toni Kalajainen
+ * @author Jani Simomaa
  */
 public class ErrorLogger {
 
-    public static final boolean ECHO = true;
-
+    private static final Logger LOGGER = LoggerFactory.getLogger(ErrorLogger.class);
     private final Plugin plugin;
     private String pluginID;
 
@@ -48,6 +49,7 @@ public class ErrorLogger {
      */
     public void logWarning(String message, Throwable exception) {
         log(IStatus.WARNING, IStatus.OK, message, exception);
+        LOGGER.warn(message, exception);
     }
 
     /**
@@ -58,6 +60,7 @@ public class ErrorLogger {
      */
     public void logMessage(String message, Throwable exception) {
         log(IStatus.INFO, IStatus.OK, message, exception);
+        LOGGER.info(message, exception);
     }
 
     /**
@@ -72,6 +75,7 @@ public class ErrorLogger {
             exception = new RuntimeException();
         }
         log(IStatus.ERROR, IStatus.OK, message, exception);
+        LOGGER.error(message, exception);
     }
 
     public void log(int severity, int code, String message, Throwable exception) {
@@ -89,27 +93,22 @@ public class ErrorLogger {
 
     public static void defaultLogError(String message, Throwable exception) {
         getDefault().logError(message, exception);
-        if(ECHO && exception != null) exception.printStackTrace();
     }
 
     public static void defaultLogError(Throwable exception) {
         getDefault().logError(getUIFriendErrorMessage(exception), exception);
-        if(ECHO && exception != null) exception.printStackTrace();
     }
 
     public static void defaultLogWarning(String message, Throwable exception) {
         getDefault().logWarning(message, exception);
-        if(ECHO && exception != null) exception.printStackTrace();
     }
 
     public static void defaultLogWarning(Throwable exception) {
         getDefault().logWarning(getUIFriendErrorMessage(exception), exception);
-        if(ECHO && exception != null) exception.printStackTrace();
     }
 
     public static void defaultLog(IStatus status) {
         getDefault().log(status);
-        if(ECHO) System.out.println(status);
     }
 
     /**