You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DefaultTrace.java 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*******************************************************************************
  2. * Copyright (c) 2006 IBM Corporation and others.
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors:
  9. * Matthew Webster - initial implementation
  10. *******************************************************************************/
  11. package org.aspectj.weaver.tools;
  12. public class DefaultTrace extends AbstractTrace {
  13. public DefaultTrace (Class clazz) {
  14. super(clazz);
  15. }
  16. public void enter (String methodName, Object thiz, Object[] args) {
  17. if (tracingEnabled) {
  18. // println("> " + tracedClass.getName() + "." + methodName + " " + formatObj(thiz) + " " + formatArgs(args));
  19. println("> " + formatMessage(tracedClass.getName(),methodName,thiz,args));
  20. }
  21. }
  22. public void enter (String methodName, Object thiz) {
  23. if (tracingEnabled) {
  24. // println("> " + tracedClass.getName() + "." + methodName + " " + formatObj(thiz));
  25. println("> " + formatMessage(tracedClass.getName(),methodName,thiz,null));
  26. }
  27. }
  28. public void exit (String methodName, Object ret) {
  29. if (tracingEnabled) {
  30. // println("< " + tracedClass.getName() + "." + methodName + " " + formatObj(ret));
  31. println("< " + formatMessage(tracedClass.getName(),methodName,ret,null));
  32. }
  33. }
  34. public void exit (String methodName) {
  35. if (tracingEnabled) {
  36. // println("< " + tracedClass.getName() + "." + methodName);
  37. println("< " + formatMessage(tracedClass.getName(),methodName,null,null));
  38. }
  39. }
  40. public void exit(String methodName, Throwable th) {
  41. exit(methodName,th);
  42. }
  43. /**
  44. * Template method that allows choice of destination for output
  45. *
  46. * @param s message to be traced
  47. */
  48. protected void println (String s) {
  49. System.err.println(s);
  50. }
  51. private static boolean tracingEnabled = getBoolean("org.aspectj.weaver.tools.tracing",false);
  52. private static boolean getBoolean (String name, boolean def) {
  53. String defaultValue = String.valueOf(def);
  54. String value = System.getProperty(name,defaultValue);
  55. return Boolean.valueOf(value).booleanValue();
  56. }
  57. }