summaryrefslogtreecommitdiffstats
path: root/loadtime/src
diff options
context:
space:
mode:
authormwebster <mwebster>2006-08-09 15:52:23 +0000
committermwebster <mwebster>2006-08-09 15:52:23 +0000
commite42bdf150dc7dda76eacf36cdb8d7ea1baa75a9e (patch)
treeca888a933ad5b543e625644150eb7aa0fd00b6a1 /loadtime/src
parentfe2b911d4aaeb0fd1a853ff2a95bd501e1dccfe3 (diff)
downloadaspectj-e42bdf150dc7dda76eacf36cdb8d7ea1baa75a9e.tar.gz
aspectj-e42bdf150dc7dda76eacf36cdb8d7ea1baa75a9e.zip
Bug 150487 "Tracing and Logging Framework" (TraceMessageHandler)
Diffstat (limited to 'loadtime/src')
-rw-r--r--loadtime/src/org/aspectj/weaver/loadtime/TraceMessageHandler.java81
1 files changed, 81 insertions, 0 deletions
diff --git a/loadtime/src/org/aspectj/weaver/loadtime/TraceMessageHandler.java b/loadtime/src/org/aspectj/weaver/loadtime/TraceMessageHandler.java
new file mode 100644
index 000000000..b661bc799
--- /dev/null
+++ b/loadtime/src/org/aspectj/weaver/loadtime/TraceMessageHandler.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * 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:
+ * Matthew Webster - initial implementation
+ *******************************************************************************/
+package org.aspectj.weaver.loadtime;
+
+import org.aspectj.bridge.AbortException;
+import org.aspectj.bridge.IMessage;
+import org.aspectj.bridge.IMessageHandler;
+import org.aspectj.bridge.WeaveMessage;
+import org.aspectj.bridge.IMessage.Kind;
+import org.aspectj.weaver.tools.Trace;
+import org.aspectj.weaver.tools.TraceFactory;
+
+public class TraceMessageHandler implements IMessageHandler {
+
+ private Trace trace;
+
+ public TraceMessageHandler () {
+ this(TraceFactory.getTraceFactory().getTrace(TraceMessageHandler.class));
+ }
+
+ /**
+ * Used for testing
+ *
+ */
+ protected TraceMessageHandler (Trace t) {
+ this.trace = t;
+ }
+
+ /* Ignore this and defer all decisions about what we log to the Trace
+ * configuration
+ */
+ public void dontIgnore(Kind kind) {
+ }
+
+ public boolean handleMessage(IMessage message) throws AbortException {
+ if (message instanceof WeaveMessage) {
+ trace.debug(render(message));
+ }
+ else if (message.isDebug()) {
+ trace.debug(render(message));
+ }
+ else if (message.isInfo()) {
+ trace.info(render(message));
+ }
+ else if (message.isWarning()) {
+ trace.warn(render(message),message.getThrown());
+ }
+ else if (message.isError()) {
+ trace.error(render(message),message.getThrown());
+ }
+ else if (message.isFailed()) {
+ trace.fatal(render(message),message.getThrown());
+ }
+ else if (message.isAbort()) {
+ trace.fatal(render(message),message.getThrown());
+ }
+ else return false;
+
+ return true;
+ }
+
+ /* Ignore this and defer all decisions about what we log to the Trace
+ * configuration
+ */
+ public boolean isIgnoring(Kind kind) {
+ return false;
+ }
+
+ protected String render(IMessage message) {
+ return message.toString();
+ }
+
+}