com.ibm.jusb.util
Class UsbTracer

java.lang.Object
  extended by com.ibm.jusb.util.UsbTracer
Direct Known Subclasses:
NullUsbTracer, StandardErrorUsbTracer, StandardOutUsbTracer

public abstract class UsbTracer
extends java.lang.Object

Class to provide abstracted tracing for javax.usb implementation(s).

This allows the javax.usb implementations (common implementation and any platform implementations) to perform tracing in a generic manner, whose output can be controlled by the user and redirected to any desired trace package or function.

To use this tracing, either create a UsbTracer object yourself with the getUsbTracer(name, level) method and use that object for all your tracing, or use the default/global UsbTracer object via UsbTracer.getUsbTracer().

Each UsbTracer object has a default name and level. The name should be used by the UsbTracer implementation, possibly be prefixing the trace message with it. The level should be used by the UsbTracer implementation, usually by printing out only messages with a higher priority that the implementation's current priority setting (which is dependent on the implementation).

Author:
Dan Streetman

Field Summary
static java.lang.String GLOBAL_TRACER_LEVEL_PROPERTY
           
static java.lang.String GLOBAL_TRACER_NAME_PROPERTY
           
static int TRACE_CRITICAL
           
static java.lang.String TRACE_CRITICAL_PROPERTY
           
static int TRACE_DEBUG
           
static java.lang.String TRACE_DEBUG_PROPERTY
           
static int TRACE_ERROR
           
static java.lang.String TRACE_ERROR_PROPERTY
           
static java.lang.String TRACE_IMPLEMENTATION_PROPERTY
           
static int TRACE_INFO
           
static java.lang.String TRACE_INFO_PROPERTY
           
static int TRACE_NOTICE
           
static java.lang.String TRACE_NOTICE_PROPERTY
           
static int TRACE_WARN
           
static java.lang.String TRACE_WARN_PROPERTY
           
 
Method Summary
 int getDefaultLevel()
          Get the default level for this UsbTracer object.
 java.lang.String getDefaultName()
          Get the default name for this UsbTracer object.
static UsbTracer getUsbTracer()
          Get the default/global UsbTracer.
static UsbTracer getUsbTracer(java.lang.String name, int level)
          Get a new UsbTracer object with the specified name and level.
 void print(int level, java.lang.String msg)
          Trace message with this UsbTracer object's default name at the specified level.
 void print(java.lang.String msg)
          Trace message with this UsbTracer object's default name and default level.
abstract  void print(java.lang.String name, int level, java.lang.String msg)
          Trace message with the specified name at the specified level.
 void print(java.lang.String name, java.lang.String msg)
          Trace message with the specified name at this UsbTracer object's default level.
 void println(int level, java.lang.String msg)
          Trace message with this UsbTracer object's default name at the specified level.
 void println(java.lang.String msg)
          Trace message with this UsbTracer object's default name and default level.
 void println(java.lang.String name, int level, java.lang.String msg)
          Trace message with the specified name at the specified level.
 void println(java.lang.String name, java.lang.String msg)
          Trace message with the specified name at this UsbTracer object's default level.
 void setDefaultLevel(int level)
          Set the default level for this UsbTracer object.
 void setDefaultName(java.lang.String name)
          Set the default name for this UsbTracer object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRACE_IMPLEMENTATION_PROPERTY

public static final java.lang.String TRACE_IMPLEMENTATION_PROPERTY
See Also:
Constant Field Values

GLOBAL_TRACER_NAME_PROPERTY

public static final java.lang.String GLOBAL_TRACER_NAME_PROPERTY
See Also:
Constant Field Values

GLOBAL_TRACER_LEVEL_PROPERTY

public static final java.lang.String GLOBAL_TRACER_LEVEL_PROPERTY
See Also:
Constant Field Values

TRACE_CRITICAL_PROPERTY

public static final java.lang.String TRACE_CRITICAL_PROPERTY
See Also:
Constant Field Values

TRACE_ERROR_PROPERTY

public static final java.lang.String TRACE_ERROR_PROPERTY
See Also:
Constant Field Values

TRACE_WARN_PROPERTY

public static final java.lang.String TRACE_WARN_PROPERTY
See Also:
Constant Field Values

TRACE_NOTICE_PROPERTY

public static final java.lang.String TRACE_NOTICE_PROPERTY
See Also:
Constant Field Values

TRACE_INFO_PROPERTY

public static final java.lang.String TRACE_INFO_PROPERTY
See Also:
Constant Field Values

TRACE_DEBUG_PROPERTY

public static final java.lang.String TRACE_DEBUG_PROPERTY
See Also:
Constant Field Values

TRACE_CRITICAL

public static final int TRACE_CRITICAL
See Also:
Constant Field Values

TRACE_ERROR

public static final int TRACE_ERROR
See Also:
Constant Field Values

TRACE_WARN

public static final int TRACE_WARN
See Also:
Constant Field Values

TRACE_NOTICE

public static final int TRACE_NOTICE
See Also:
Constant Field Values

TRACE_INFO

public static final int TRACE_INFO
See Also:
Constant Field Values

TRACE_DEBUG

public static final int TRACE_DEBUG
See Also:
Constant Field Values
Method Detail

print

public abstract void print(java.lang.String name,
                           int level,
                           java.lang.String msg)
Trace message with the specified name at the specified level.

Parameters:
name - The name of the trace source.
level - The trace level of the message.
msg - The trace message.

println

public void println(java.lang.String name,
                    int level,
                    java.lang.String msg)
Trace message with the specified name at the specified level.

This appends a newline to the message.

Parameters:
name - The name of the trace source.
level - The trace level of the message.
msg - The trace message.

print

public void print(java.lang.String name,
                  java.lang.String msg)
Trace message with the specified name at this UsbTracer object's default level.

Parameters:
name - The name of the trace source.
msg - The trace message.

println

public void println(java.lang.String name,
                    java.lang.String msg)
Trace message with the specified name at this UsbTracer object's default level.

This appends a newline to the message.

Parameters:
name - The name of the trace source.
msg - The trace message.

print

public void print(int level,
                  java.lang.String msg)
Trace message with this UsbTracer object's default name at the specified level.

Parameters:
level - The trace level of the message.
msg - The trace message.

println

public void println(int level,
                    java.lang.String msg)
Trace message with this UsbTracer object's default name at the specified level.

This appends a newline to the message.

Parameters:
level - The trace level of the message.
msg - The trace message.

print

public void print(java.lang.String msg)
Trace message with this UsbTracer object's default name and default level.

Parameters:
msg - The trace message.

println

public void println(java.lang.String msg)
Trace message with this UsbTracer object's default name and default level.

This appends a newline to the message.

Parameters:
msg - The trace message.

setDefaultName

public void setDefaultName(java.lang.String name)
Set the default name for this UsbTracer object.

Parameters:
name - The default name.

getDefaultName

public java.lang.String getDefaultName()
Get the default name for this UsbTracer object.

Returns:
The default name.

setDefaultLevel

public void setDefaultLevel(int level)
Set the default level for this UsbTracer object.

Parameters:
level - The default level.

getDefaultLevel

public int getDefaultLevel()
Get the default level for this UsbTracer object.

Returns:
The default level.

getUsbTracer

public static UsbTracer getUsbTracer(java.lang.String name,
                                     int level)
Get a new UsbTracer object with the specified name and level.

Parameters:
name - The default trace name for the new UsbTracer.
level - The default trace level for the new UsbTracer.
Returns:
A new UsbTracer object.

getUsbTracer

public static UsbTracer getUsbTracer()
Get the default/global UsbTracer.

This should be used for easy tracing access. The default/global UsbTracer object is returned. Its name defaults to "Main UsbTracer" and level to TRACE_DEBUG. Both are settable from the javax.usb.properties file.

Returns:
The global/main UsbTracer.