X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.common%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fcommon%2Futils%2FErrorLogger.java;h=68ad37438016cc9e4b9d5411c2ccca2ae82f7e5b;hb=035118aa5f35c9e5acd1f34d22065055dfdee486;hp=4bd12179e135df1772058bd15fa17b3492705477;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git
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
index 4bd12179e..68ad37438 100644
--- 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
@@ -1,115 +1,115 @@
-/*******************************************************************************
- * 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);
- }
-}
+/*******************************************************************************
+ * 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);
+ }
+}