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

CLog()

Public methods

static void d(String message)

The shim version of Log#d(String, String).

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

The shim version of Log#d(String, String).

static void e(String message)

The shim version of Log#e(String, String).

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

The shim version of Log#e(String, String).

static void e(Throwable t)

The shim version of Log#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 format, Object... args)

The shim version of Log#i(String, String).

static void i(String message)

The shim version of Log#i(String, String).

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

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

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

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

static String parseClassName(String fullName)

Parses the simple class name out of the full class name.

static void v(String message)

The shim version of Log#v(String, String).

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

The shim version of Log#v(String, String).

static void w(Throwable t)

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

static void w(String message)

The shim version of Log#w(String, String).

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

The shim version of Log#w(String, String).

static void wtf(String message)

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 format, Object... args)

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

protected static final String CLASS_NAME

Public constructors

CLog

public CLog ()

Public methods

d

public static void d (String message)

The shim version of Log#d(String, String).

Parameters
message String: The String to log

d

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

The shim version of Log#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

public static void e (String message)

The shim version of Log#e(String, String).

Parameters
message String: The String to log

e

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

The shim version of Log#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

public static void e (Throwable t)

The shim version of Log#e(String, Throwable).

Parameters
t Throwable: the Throwable to output.

findCallerClassName

public static 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

public static 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

public static 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

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

The shim version of Log#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

i

public static void i (String message)

The shim version of Log#i(String, String).

Parameters
message String: The String to log

logAndDisplay

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

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

Parameters
logLevel Log.LogLevel: the LogLevel

format String: A format string for the message to log

args Object: The format string arguments

logAndDisplay

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

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

Parameters
logLevel Log.LogLevel: the LogLevel

message String: The String to log

parseClassName

public static String parseClassName (String fullName)

Parses the simple class name out of the full class name. If the formatting already looks like a simple class name, then just returns that.

Parameters
fullName String: the full class name to parse

Returns
String The simple class name

v

public static void v (String message)

The shim version of Log#v(String, String).

Parameters
message String: The String to log

v

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

The shim version of Log#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

public static void w (Throwable t)

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

Parameters
t Throwable: The Throwable to log

w

public static void w (String message)

The shim version of Log#w(String, String).

Parameters
message String: The String to log

w

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

The shim version of Log#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

public static 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

public static 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

public static 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

public static 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.