-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.db.common.utils;\r
-\r
-import java.util.Properties;\r
-\r
-import org.apache.log4j.Logger;\r
-\r
-/*\r
- * \r
- * @deprecated in favor of org.simantics.db.common.Logger. Will be removed in Simantics 1.2\r
- * \r
- */\r
-@Deprecated\r
-public class ErrorLogger {\r
- public static final boolean ECHO = false;\r
- public static final Properties defaultProperties = new Properties();\r
- static {\r
- defaultProperties.put("log4j.rootCategory", "ERROR, default");\r
- defaultProperties.put("log4j.appender.default", "org.apache.log4j.FileAppender");\r
- defaultProperties.put("log4j.appender.default.File", "db-client-deprecated.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 [%15.15t] %-5p %30.30c - %m%n");\r
- }\r
- private static LogManager defaultLogManager = new LogManager(defaultProperties);\r
- private static final ErrorLogger defaultErrorLogger = new ErrorLogger(LogManager.class);\r
- private Logger logger;\r
- ErrorLogger(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 (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 (exception == null) {\r
- exception = new RuntimeException();\r
- }\r
- logger.info(message, exception);\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 (exception == null) {\r
- exception = new RuntimeException();\r
- }\r
- logger.error(message, exception);\r
- }\r
-\r
- public static ErrorLogger getDefault() {\r
- return defaultErrorLogger;\r
- }\r
- \r
- public static LogManager getDefaultLogManager() {\r
- return defaultLogManager;\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
- public static void defaultLogTrace(String message) {\r
- getDefault().logTrace(message, null);\r
- if(ECHO)\r
- System.err.println(message);\r
- }\r
-}\r
+/*******************************************************************************
+ * 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 <code>null</code>
+ */
+ 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 <code>null</code>
+ */
+ 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 <code>null</code>
+ */
+ 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);
+ }
+}