bsharp.tracing
Class Trace

java.lang.Object
  extended by bsharp.tracing.Trace

public class Trace
extends java.lang.Object

A useful collection of commonly used tracing functionality including: All trace messages are sychronized so messages from different threads don't interleave All trace messages are flush()-ed for convenience All Trace messages are prepened with the current classname and method. A method to get the current method name A method to get a classes 'simpleName' not availible until Java 1.5 A method to print out all the current running threads.

Author:
brandon@sharpideas.ca

Method Summary
static java.lang.String arrayToString(java.lang.Object[] array)
           
static void errPrintln(java.lang.String message)
          Prints message to System.err.
static void errPrintlnP(java.lang.String message)
          Prints message to System.err.
static java.lang.String getClassSimpleName(java.lang.Class aClass)
          Get the string representation of a Classes 'simple name' with Java 1.1 compatibility.
static java.lang.String getCurrentClassAndMethodName()
          Return the name of class and method that called getCurrentMethodName.
static java.lang.String getCurrentClassAndMethodName(int depth)
          Return the name of class and method that called getCurrentMethodName.
static java.lang.String getCurrentMethodName()
          Return the name of the routine that called getCurrentMethodName.
static java.lang.String getCurrentMethodName(int depth)
          Return the name of the routine that called getCurrentMethodName.
static void println(java.lang.String message)
          Prints a message, synchronized.
static void printlnP(java.lang.String message)
          Prints a message, synchronized, and Prefixed with Class and method name.
static void printThreads()
          Prints out the currently running threads.
static void printThreadsP()
          Prints out the currently running threads, Prefixed with current class and method name.
static void traceHex(byte[] data)
          Trace a byte array in hex, synchronized.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getClassSimpleName

public static java.lang.String getClassSimpleName(java.lang.Class aClass)
Get the string representation of a Classes 'simple name' with Java 1.1 compatibility. Like Class.getSimpleName() in Java 1.5.


println

public static void println(java.lang.String message)
Prints a message, synchronized.
- Also flushes System.out.
- And synchronizes messages on the Trace class.


printlnP

public static void printlnP(java.lang.String message)
Prints a message, synchronized, and Prefixed with Class and method name.
- Also flushes System.out.
- And synchronizes messages on the Trace class.


errPrintln

public static void errPrintln(java.lang.String message)
Prints message to System.err.
- Also flushes System.err.
- And synchronizes messages on the Trace class.


errPrintlnP

public static void errPrintlnP(java.lang.String message)
Prints message to System.err. Prefixed with Class and method name.
- Also flushes System.err.
- And synchronizes messages on the Trace class.


printThreads

public static void printThreads()
Prints out the currently running threads.
- Also flushes System.out.
- And synchronizes messages on the Trace class.


printThreadsP

public static void printThreadsP()
Prints out the currently running threads, Prefixed with current class and method name.
- Also flushes System.out.
- And synchronizes messages on the Trace class.


getCurrentMethodName

public static java.lang.String getCurrentMethodName()
Return the name of the routine that called getCurrentMethodName.


getCurrentMethodName

public static java.lang.String getCurrentMethodName(int depth)
Return the name of the routine that called getCurrentMethodName.

Parameters:
depth - where 0 is the method called getCurrentMethodName(), 1 is the method that called that etc.

getCurrentClassAndMethodName

public static java.lang.String getCurrentClassAndMethodName()
Return the name of class and method that called getCurrentMethodName.


getCurrentClassAndMethodName

public static java.lang.String getCurrentClassAndMethodName(int depth)
Return the name of class and method that called getCurrentMethodName.

Parameters:
depth - where 0 is the method called getCurrentMethodName(), 1 is the method that called that etc.

traceHex

public static void traceHex(byte[] data)
Trace a byte array in hex, synchronized.

Parameters:
data -

arrayToString

public static java.lang.String arrayToString(java.lang.Object[] array)