LogUtil.CLog

public static class LogUtil.CLog
extends Object

java.lang.Object
   ↳ com.android.tradefed.log.LogUtil.CLog


A shim class for Log that automatically uses the simple classname of the caller as the log tag

Summary

Fields

protected static final String CLASS_NAME

Public constructors

LogUtil.CLog()

Public methods

static void d(String message)

The shim version of d(String, String).

static void d(String format, Object... args)

The shim version of d(String, String).

static void e(String format, Object... args)

The shim version of e(String, String).

static void e(String message)

The shim version of e(String, String).

static void e(Throwable t)

The shim version of e(String, Throwable).

static String findCallerClassName()

Finds the external class name that directly called a CLog method.

static String findCallerClassName(Throwable t)

Finds the external class name that directly called a CLog method.

static String getClassName(int frame)

Return the simple classname from the frameth stack frame in the call path.

static void i(String message)

The shim version of i(String, String).

static void i(String format, Object... args)

The shim version of i(String, String).

static void logAndDisplay(Log.LogLevel logLevel, String format, Object... args)

The shim version of logAndDisplay(LogLevel, String, String).

static void logAndDisplay(Log.LogLevel logLevel, String message)

The shim version of logAndDisplay(LogLevel, String, String).

static void setGlobalConfigInstance(IGlobalConfiguration globalConfig)

Sets the GlobalConfiguration instance for CLog to use - exposed for unit testing

static void v(String message)

The shim version of v(String, String).

static void v(String format, Object... args)

The shim version of v(String, String).

static void w(Throwable t)

A variation of w(String, String), where the stack trace of provided Throwable is formatted and logged.

static void w(String message)

The shim version of w(String, String).

static void w(String format, Object... args)

The shim version of w(String, String).

static void wtf(String message)

What a Terrible Failure: Report a condition that should never happen.

static void wtf(String format, Object... args)

What a Terrible Failure: Report a condition that should never happen.

static void wtf(Throwable t)

What a Terrible Failure: Report a condition that should never happen.

static void wtf(String message, Throwable t)

What a Terrible Failure: Report a condition that should never happen.

Fields

CLASS_NAME

String CLASS_NAME

Public constructors

LogUtil.CLog

LogUtil.CLog ()

Public methods

d

void d (String message)

The shim version of d(String, String).

Parameters
message String: The String to log

d

void d (String format, 
                Object... args)

The shim version of d(String, String). Also calls String.format for convenience.

Parameters
format String: A format string for the message to log

args Object: The format string arguments

e

void e (String format, 
                Object... args)

The shim version of e(String, String). Also calls String.format for convenience.

Parameters
format String: A format string for the message to log

args Object: The format string arguments

e

void e (String message)

The shim version of e(String, String).

Parameters
message String: The String to log

e

void e (Throwable t)

The shim version of e(String, Throwable).

Parameters
t Throwable: the Throwable to output.

findCallerClassName

String findCallerClassName ()

Finds the external class name that directly called a CLog method.

Returns
String The simple class name (or full-qualified if an error occurs getting a ref to the class) of the external class that called a CLog method, or "Unknown" if the stack trace is empty or only contains CLog class names.

findCallerClassName

String findCallerClassName (Throwable t)

Finds the external class name that directly called a CLog method.

Parameters
t Throwable: (Optional) the stack trace to search within, exposed for unit testing

Returns
String The simple class name (or full-qualified if an error occurs getting a ref to the class) of the external class that called a CLog method, or "Unknown" if the stack trace is empty or only contains CLog class names.

getClassName

String getClassName (int frame)

Return the simple classname from the frameth stack frame in the call path. Note: this method does not check array bounds for the stack trace length.

Parameters
frame int: The index of the stack trace frame to inspect for the class name

Returns
String The simple class name (or full-qualified if an error occurs getting a ref to the class) for the given element of the stack trace.

i

void i (String message)

The shim version of i(String, String).

Parameters
message String: The String to log

i

void i (String format, 
                Object... args)

The shim version of i(String, String). Also calls String.format for convenience.

Parameters
format String: A format string for the message to log

args Object: The format string arguments

logAndDisplay

void logAndDisplay (Log.LogLevel logLevel, 
                String format, 
                Object... args)

The shim version of logAndDisplay(LogLevel, String, String).

Parameters
logLevel Log.LogLevel: the Log.LogLevel

format String: A format string for the message to log

args Object: The format string arguments

logAndDisplay

void logAndDisplay (Log.LogLevel logLevel, 
                String message)

The shim version of logAndDisplay(LogLevel, String, String).

Parameters
logLevel Log.LogLevel: the Log.LogLevel

message String: The String to log

setGlobalConfigInstance

void setGlobalConfigInstance (IGlobalConfiguration globalConfig)

Sets the GlobalConfiguration instance for CLog to use - exposed for unit testing

Parameters
globalConfig IGlobalConfiguration: the GlobalConfiguration object for CLog to use

v

void v (String message)

The shim version of v(String, String).

Parameters
message String: The String to log

v

void v (String format, 
                Object... args)

The shim version of v(String, String). Also calls String.format for convenience.

Parameters
format String: A format string for the message to log

args Object: The format string arguments

w

void w (Throwable t)

A variation of w(String, String), where the stack trace of provided Throwable is formatted and logged.

Parameters
t Throwable: The Throwable to log

w

void w (String message)

The shim version of w(String, String).

Parameters
message String: The String to log

w

void w (String format, 
                Object... args)

The shim version of w(String, String). Also calls String.format for convenience.

Parameters
format String: A format string for the message to log

args Object: The format string arguments

wtf

void wtf (String message)

What a Terrible Failure: Report a condition that should never happen. The error will always be logged at level ASSERT with the call stack.

Parameters
message String: The message you would like logged.

wtf

void wtf (String format, 
                Object... args)

What a Terrible Failure: Report a condition that should never happen. The error will always be logged at level ASSERT with the call stack. Also calls String.format for convenience.

Parameters
format String: A format string for the message to log

args Object: The format string arguments

wtf

void wtf (Throwable t)

What a Terrible Failure: Report a condition that should never happen. The error will always be logged at level ASSERT with the call stack.

Parameters
t Throwable: (Optional) An exception to log. If null, only message will be logged.

wtf

void wtf (String message, 
                Throwable t)

What a Terrible Failure: Report a condition that should never happen. The error will always be logged at level ASSERT with the call stack.

Parameters
message String: The message you would like logged.

t Throwable: (Optional) An exception to log. If null, only message will be logged.