You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@depot.apache.org by aj...@apache.org on 2004/05/26 18:43:10 UTC
svn commit: rev 20488 - in incubator/depot/trunk/common/src/java/org/apache/depot/common/ant: . util
Author: ajack
Date: Wed May 26 11:43:09 2004
New Revision: 20488
Added:
incubator/depot/trunk/common/src/java/org/apache/depot/common/ant/
incubator/depot/trunk/common/src/java/org/apache/depot/common/ant/util/
incubator/depot/trunk/common/src/java/org/apache/depot/common/ant/util/AntLogListener.java
Log:
Still trying to get this into SVN...
Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/ant/util/AntLogListener.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/ant/util/AntLogListener.java Wed May 26 11:43:09 2004
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.depot.common.ant.util;
+
+import org.apache.depot.common.log.ILogger;
+import org.apache.depot.common.log.LogConstants;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.ProjectComponent;
+
+/**
+ * @author arb_jack
+ */
+public class AntLogListener implements ILogger {
+
+ private ProjectComponent m_component = null;
+
+ public AntLogListener(ProjectComponent component) {
+ m_component = component;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.version.log.LogListener#log(int, java.lang.Object,
+ * java.lang.Throwable)
+ */
+ public void log(int severity, Object message, Throwable thrower) {
+ int antSeverity = Project.MSG_ERR;
+
+ try {
+
+ switch (severity) {
+ case LogConstants.DEBUG :
+ {
+ antSeverity = Project.MSG_DEBUG;
+ break;
+ }
+ case LogConstants.INFO :
+ {
+ antSeverity = Project.MSG_INFO;
+ break;
+ }
+ case LogConstants.VERBOSE :
+ {
+ antSeverity = Project.MSG_VERBOSE;
+ break;
+ }
+ case LogConstants.WARN :
+ {
+ antSeverity = Project.MSG_WARN;
+ break;
+ }
+ default :
+ case LogConstants.ERROR :
+ {
+ antSeverity = Project.MSG_ERR;
+ break;
+ }
+ }
+
+ StringBuffer messageStr = new StringBuffer(message.toString());
+
+ if (null != thrower) {
+ appendThrower(messageStr, thrower);
+ }
+
+ m_component.log(messageStr.toString(), antSeverity);
+
+ } catch (Throwable t) {
+ m_component.log("Failed to log message : " + t.toString());
+ t.printStackTrace(System.err);
+ }
+ }
+
+ private void appendThrower(StringBuffer messageStr, Throwable thrower) {
+
+ messageStr.append(thrower.getLocalizedMessage());
+
+ StackTraceElement stacks[] = thrower.getStackTrace();
+
+ if (null != stacks)
+ for (int i = 0; i < stacks.length; ++i) {
+ messageStr.append("\n");
+ messageStr.append(stacks[i].toString());
+ }
+
+ // Note: not JDK 1.3, but I don't think we care
+ Throwable cause = thrower.getCause();
+ if (null != cause) {
+ messageStr.append("Cause: \n");
+ appendThrower(messageStr, cause);
+ }
+ }
+}