LogUtil.CLog

public static class LogUtil.CLog
extends Object

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


Log 的 shim 类,可自动将调用者的简单类名称用作日志标记

摘要

字段

protected static final String CLASS_NAME

公共构造函数

CLog()

公共方法

static void d(String message)

Log.d(String, String) 的 shim 版本。

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

Log.d(String, String) 的 shim 版本。

static void e(String message)

Log.e(String, String) 的 shim 版本。

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

Log.e(String, String) 的 shim 版本。

static void e(Throwable t)

Log.e(String, Throwable) 的 shim 版本。

static String findCallerClassName()

查找直接调用 CLog 方法的外部类名称。

static String findCallerClassName(Throwable t)

查找直接调用 CLog 方法的外部类名称。

static String getClassName(int frame)

返回调用路径中第 frame 个堆栈帧的简单类名称。

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

Log.i(String, String) 的 shim 版本。

static void i(String message)

Log.i(String, String) 的 shim 版本。

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

ERROR(Log.logAndDisplay(LogLevel, String, String)/com.android.tradefed.log.Log#logAndDisplay(com.android.ddmlib.Log.LogLevel,String,String) Log.logAndDisplay(LogLevel, String, String)) 的 shim 版本。

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

ERROR(Log.logAndDisplay(LogLevel, String, String)/com.android.tradefed.log.Log#logAndDisplay(com.android.ddmlib.Log.LogLevel,String,String) Log.logAndDisplay(LogLevel, String, String)) 的 shim 版本。

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

ERROR(Log.logAndDisplay(LogLevel, String, String)/com.android.tradefed.log.Log#logAndDisplay(com.android.ddmlib.Log.LogLevel,String,String) Log.logAndDisplay(LogLevel, String, String)) 的 shim 版本。

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

从完整类名中解析出简单类名。

static void v(String message)

Log.v(String, String) 的 shim 版本。

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

Log.v(String, String) 的 shim 版本。

static void w(Throwable t)

Log.w(String, String) 的变体,用于格式化和记录所提供 Throwable 的堆栈轨迹。

static void w(String message)

Log.w(String, String) 的 shim 版本。

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

Log.w(String, String) 的 shim 版本。

static void wtf(String message)

What a Terrible Failure:报告不应发生的情况。

static void wtf(Throwable t)

What a Terrible Failure:报告不应发生的情况。

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

What a Terrible Failure:报告不应发生的情况。

static void wtf(String message, Throwable t)

What a Terrible Failure:报告不应发生的情况。

字段

CLASS_NAME

protected static final String CLASS_NAME

公共构造函数

CLog

public CLog ()

公共方法

d

public static void d (String message)

Log.d(String, String) 的 shim 版本。

参数
message String:要记录的 String

d

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

Log.d(String, String) 的 shim 版本。还调用 String.format 以提供便利。

参数
format String:要记录的消息的格式字符串

args Object:格式字符串实参

e

public static void e (String message)

Log.e(String, String) 的 shim 版本。

参数
message String:要记录的 String

e

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

Log.e(String, String) 的 shim 版本。还调用 String.format 以提供便利。

参数
format String:要记录的消息的格式字符串

args Object:格式字符串实参

e

public static void e (Throwable t)

Log.e(String, Throwable) 的 shim 版本。

参数
t Throwable:要输出的 Throwable

findCallerClassName

public static String findCallerClassName ()

查找直接调用 CLog 方法的外部类名称。

返回
String 调用 CLog 方法的外部类的简单类名称(如果获取类引用时发生错误,则为完全限定的类名称),如果堆栈轨迹为空或仅包含 CLog 类名称,则为“Unknown”。

findCallerClassName

public static String findCallerClassName (Throwable t)

查找直接调用 CLog 方法的外部类名称。

参数
t Throwable:(可选)要搜索的堆栈轨迹,用于单元测试

返回
String 调用 CLog 方法的外部类的简单类名称(如果获取类引用时发生错误,则为完全限定的类名称),如果堆栈轨迹为空或仅包含 CLog 类名称,则为“Unknown”。

getClassName

public static String getClassName (int frame)

返回调用路径中第 frame 个堆栈帧的简单类名称。 注意:此方法会检查堆栈轨迹长度的数组边界。

参数
frame int:要检查的堆栈轨迹帧的索引(用于获取类名称)

返回
String 给定堆栈轨迹元素的简单类名称(如果获取类引用时发生错误,则为完全限定名称)。

i

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

Log.i(String, String) 的 shim 版本。还调用 String.format 以提供便利。

参数
format String:要记录的消息的格式字符串

args Object:格式字符串实参

i

public static void i (String message)

Log.i(String, String) 的 shim 版本。

参数
message String:要记录的 String

logAndDisplay

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

ERROR(Log.logAndDisplay(LogLevel, String, String)/com.android.tradefed.log.Log#logAndDisplay(com.android.ddmlib.Log.LogLevel,String,String) Log.logAndDisplay(LogLevel, String, String)) 的 shim 版本。

参数
logLevel Log.LogLevelLogLevel

format String:要记录的消息的格式字符串

args Object:格式字符串实参

logAndDisplay

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

ERROR(Log.logAndDisplay(LogLevel, String, String)/com.android.tradefed.log.Log#logAndDisplay(com.android.ddmlib.Log.LogLevel,String,String) Log.logAndDisplay(LogLevel, String, String)) 的 shim 版本。

参数
logLevel Log.LogLevelLogLevel

format String:要记录的消息的格式字符串

args Object:格式字符串实参

logAndDisplay

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

ERROR(Log.logAndDisplay(LogLevel, String, String)/com.android.tradefed.log.Log#logAndDisplay(com.android.ddmlib.Log.LogLevel,String,String) Log.logAndDisplay(LogLevel, String, String)) 的 shim 版本。

参数
logLevel Log.LogLevelLogLevel

message String:要记录的 String

logAndDisplay

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

参数
logLevel Log.LogLevel

message String

parseClassName

public static String parseClassName (String fullName)

从完整类名中解析出简单类名。如果格式已类似于简单的类名称,则只需返回该名称。

参数
fullName String:要解析的完整类名

返回
String 简单类名称

v

public static void v (String message)

Log.v(String, String) 的 shim 版本。

参数
message String:要记录的 String

v

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

Log.v(String, String) 的 shim 版本。还调用 String.format 以提供便利。

参数
format String:要记录的消息的格式字符串

args Object:格式字符串实参

W

public static void w (Throwable t)

Log.w(String, String) 的变体,用于格式化和记录所提供的 Throwable 的堆栈轨迹。

参数
t Throwable:要记录的 Throwable

W

public static void w (String message)

Log.w(String, String) 的 shim 版本。

参数
message String:要记录的 String

W

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

Log.w(String, String) 的 shim 版本。还调用 String.format 以提供便利。

参数
format String:要记录的消息的格式字符串

args Object:格式字符串实参

wtf

public static void wtf (String message)

What a Terrible Failure:报告不应发生的情况。 系统始终会以 ASSERT 级别记录此错误以及调用堆栈。

参数
message String:您要记录的消息。

wtf

public static void wtf (Throwable t)

What a Terrible Failure:报告不应发生的情况。 系统始终会以 ASSERT 级别记录此错误以及调用堆栈。

参数
t Throwable:(可选)要记录的异常。如果为 null,则仅记录消息。

wtf

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

What a Terrible Failure:报告不应发生的状况。 系统始终会以 ASSERT 级别记录此错误,并附带调用堆栈。还调用 String.format 以提供便利。

参数
format String:要记录的消息的格式字符串

args Object:格式字符串实参

wtf

public static void wtf (String message, 
                Throwable t)

What a Terrible Failure:报告不应发生的情况。 系统始终会以 ASSERT 级别记录此错误以及调用堆栈。

参数
message String:您要记录的消息。

t Throwable:(可选)要记录的异常。如果为 null,则仅记录消息。