From 62fc65d6dff5acd55e872d7314a617d618c66d04 Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Wed, 7 Nov 2018 11:23:34 +0200 Subject: [PATCH] Fix ErrorLogger e.printStackTrace() calls to utilize Logger gitlab #182 Change-Id: I5903cd25c70de18b4bf21714d4a1106ccf3dfed7 --- .../src/org/simantics/utils/ui/ErrorLogger.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/ErrorLogger.java b/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/ErrorLogger.java index 62fe87bad..c8c49d17d 100644 --- a/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/ErrorLogger.java +++ b/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/ErrorLogger.java @@ -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); } /** -- 2.47.1