diff options
author | mwebster <mwebster> | 2006-07-14 17:39:46 +0000 |
---|---|---|
committer | mwebster <mwebster> | 2006-07-14 17:39:46 +0000 |
commit | b15cda7add8a6d7f288ce6132c9c2cd328bba7bc (patch) | |
tree | 2a5ce1c68f4fc021f1124c033b35c910cc132dcb /weaver5 | |
parent | b1024db14f7290378784988e14dffd2def5c251f (diff) | |
download | aspectj-b15cda7add8a6d7f288ce6132c9c2cd328bba7bc.tar.gz aspectj-b15cda7add8a6d7f288ce6132c9c2cd328bba7bc.zip |
First drop of Bug 150487 "Tracing and Logging Framework" (Trace & TraceFactory)
Diffstat (limited to 'weaver5')
-rw-r--r-- | weaver5/java5-src/org/aspectj/weaver/tools/Jdk14Trace.java | 63 | ||||
-rw-r--r-- | weaver5/java5-src/org/aspectj/weaver/tools/Jdk14TraceFactory.java | 20 | ||||
-rw-r--r-- | weaver5/testdata/logging.properties | 59 |
3 files changed, 142 insertions, 0 deletions
diff --git a/weaver5/java5-src/org/aspectj/weaver/tools/Jdk14Trace.java b/weaver5/java5-src/org/aspectj/weaver/tools/Jdk14Trace.java new file mode 100644 index 000000000..93d816d90 --- /dev/null +++ b/weaver5/java5-src/org/aspectj/weaver/tools/Jdk14Trace.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * 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.tools; + +import java.util.logging.Level; +import java.util.logging.Logger; + +public class Jdk14Trace extends AbstractTrace { + + private Logger logger; + private String name; + + public Jdk14Trace (Class clazz) { + super(clazz); + this.name = clazz.getName(); + this.logger = Logger.getLogger(name); + } + + public void enter(String methodName, Object thiz, Object[] args) { + if (logger.isLoggable(Level.FINE)) { + logger.entering(name,methodName,formatObj(thiz)); + if (args != null && logger.isLoggable(Level.FINER)) { + logger.entering(name,methodName,args); + } + } + } + + public void enter(String methodName, Object thiz) { + enter(methodName,thiz,null); + } + + public void exit(String methodName, Object ret) { + if (logger.isLoggable(Level.FINE)) { + logger.exiting(name,methodName,ret); + } + } + + public void exit(String methodName, Throwable th) { + if (logger.isLoggable(Level.FINE)) { + logger.exiting(name,methodName,th); + } + } + + public void exit(String methodName) { + if (logger.isLoggable(Level.FINE)) { + logger.exiting(name,methodName); + } + } + + @Override + public boolean isTraceEnabled() { + return logger.isLoggable(Level.FINE); + } + +} diff --git a/weaver5/java5-src/org/aspectj/weaver/tools/Jdk14TraceFactory.java b/weaver5/java5-src/org/aspectj/weaver/tools/Jdk14TraceFactory.java new file mode 100644 index 000000000..4043d1d33 --- /dev/null +++ b/weaver5/java5-src/org/aspectj/weaver/tools/Jdk14TraceFactory.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * 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.tools; + +public class Jdk14TraceFactory extends TraceFactory { + + @Override + public Trace getTrace(Class clazz) { + return new Jdk14Trace(clazz); + } + +} diff --git a/weaver5/testdata/logging.properties b/weaver5/testdata/logging.properties new file mode 100644 index 000000000..fb96358eb --- /dev/null +++ b/weaver5/testdata/logging.properties @@ -0,0 +1,59 @@ +############################################################ +# Default Logging Configuration File +# +# You can use a different file by specifying a filename +# with the java.util.logging.config.file system property. +# For example java -Djava.util.logging.config.file=myfile +############################################################ + +############################################################ +# Global properties +############################################################ + +# "handlers" specifies a comma separated list of log Handler +# classes. These handlers will be installed during VM startup. +# Note that these classes must be on the system classpath. +# By default we only configure a ConsoleHandler, which will only +# show messages at the INFO and above levels. +#handlers= java.util.logging.ConsoleHandler + +# To also add the FileHandler, use the following line instead. +#handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler +handlers= java.util.logging.FileHandler + +# Default global logging level. +# This specifies which kinds of events are logged across +# all loggers. For any given facility this global level +# can be overriden by a facility specific level +# Note that the ConsoleHandler also has a separate level +# setting to limit messages printed to the console. +.level= INFO + +############################################################ +# Handler specific properties. +# Describes specific configuration info for Handlers. +############################################################ + +# default file output is in user's home directory. +java.util.logging.FileHandler.pattern = %h/java%u.log +#java.util.logging.FileHandler.limit = 50000 +java.util.logging.FileHandler.count = 1 +#java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter +java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter +java.util.logging.FileHandler.level = FINER + +# Limit the message that are printed on the console to INFO and above. +java.util.logging.ConsoleHandler.level = FINER +java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter + + +############################################################ +# Facility specific properties. +# Provides extra control for each logger. +############################################################ + +# For example, set the com.xyz.foo logger to only log SEVERE +# messages: +#com.xyz.foo.level = SEVERE +org.aspectj.weaver.level = FINER +org.aspectj.weaver.loadtime.level = FINER |