|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecta_vcard.android.util.Log
public final class Log
API for sending log output.
Generally, use the Log.v() Log.d() Log.i() Log.w() and Log.e() methods.
The order in terms of verbosity, from least to most is ERROR, WARN, INFO, DEBUG, VERBOSE. Verbose should never be compiled into an application except during development. Debug logs are compiled in but stripped at runtime. Error, warning and info logs are always kept.
Tip: A good convention is to declare a TAG
constant
in your class:
private static final String TAG = "MyActivity";and use that in subsequent calls to the log methods.
Tip: Don't forget that when you make a call like
Log.v(TAG, "index=" + i);that when you're building the string to pass into Log.d, the compiler uses a StringBuilder and at least three allocations occur: the StringBuilder itself, the buffer, and the String object. Realistically, there is also another buffer allocation and copy, and even more pressure on the gc. That means that if your log message is filtered out, you might be doing significant work and incurring significant overhead.
Field Summary | |
---|---|
static int |
ASSERT
Priority constant for the println method. |
static int |
DEBUG
Priority constant for the println method; use Log.d. |
static int |
ERROR
Priority constant for the println method; use Log.e. |
static int |
INFO
Priority constant for the println method; use Log.i. |
static int |
VERBOSE
Priority constant for the println method; use Log.v. |
static int |
WARN
Priority constant for the println method; use Log.w. |
Method Summary | |
---|---|
static int |
d(java.lang.String tag,
java.lang.String msg)
Send a DEBUG log message. |
static int |
d(java.lang.String tag,
java.lang.String msg,
java.lang.Throwable tr)
Send a DEBUG log message and log the exception. |
static int |
e(java.lang.String tag,
java.lang.String msg)
Send an ERROR log message. |
static int |
e(java.lang.String tag,
java.lang.String msg,
java.lang.Throwable tr)
Send a ERROR log message and log the exception. |
static java.lang.String |
getStackTraceString(java.lang.Throwable tr)
Handy function to get a loggable stack trace from a Throwable |
static int |
i(java.lang.String tag,
java.lang.String msg)
Send an INFO log message. |
static int |
i(java.lang.String tag,
java.lang.String msg,
java.lang.Throwable tr)
Send a INFO log message and log the exception. |
static boolean |
isLoggable(java.lang.String tag,
int level)
Checks to see whether or not a log for the specified tag is loggable at the specified level. |
static int |
println(int priority,
java.lang.String tag,
java.lang.String msg)
Low-level logging call. |
static int |
v(java.lang.String tag,
java.lang.String msg)
Send a VERBOSE log message. |
static int |
v(java.lang.String tag,
java.lang.String msg,
java.lang.Throwable tr)
Send a VERBOSE log message and log the exception. |
static int |
w(java.lang.String tag,
java.lang.String msg)
Send a WARN log message. |
static int |
w(java.lang.String tag,
java.lang.String msg,
java.lang.Throwable tr)
Send a WARN log message and log the exception. |
static int |
w(java.lang.String tag,
java.lang.Throwable tr)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int VERBOSE
public static final int DEBUG
public static final int INFO
public static final int WARN
public static final int ERROR
public static final int ASSERT
Method Detail |
---|
public static int v(java.lang.String tag, java.lang.String msg)
VERBOSE
log message.
tag
- Used to identify the source of a log message. It usually identifies
the class or activity where the log call occurs.msg
- The message you would like logged.public static int v(java.lang.String tag, java.lang.String msg, java.lang.Throwable tr)
VERBOSE
log message and log the exception.
tag
- Used to identify the source of a log message. It usually identifies
the class or activity where the log call occurs.msg
- The message you would like logged.tr
- An exception to logpublic static int d(java.lang.String tag, java.lang.String msg)
DEBUG
log message.
tag
- Used to identify the source of a log message. It usually identifies
the class or activity where the log call occurs.msg
- The message you would like logged.public static int d(java.lang.String tag, java.lang.String msg, java.lang.Throwable tr)
DEBUG
log message and log the exception.
tag
- Used to identify the source of a log message. It usually identifies
the class or activity where the log call occurs.msg
- The message you would like logged.tr
- An exception to logpublic static int i(java.lang.String tag, java.lang.String msg)
INFO
log message.
tag
- Used to identify the source of a log message. It usually identifies
the class or activity where the log call occurs.msg
- The message you would like logged.public static int i(java.lang.String tag, java.lang.String msg, java.lang.Throwable tr)
INFO
log message and log the exception.
tag
- Used to identify the source of a log message. It usually identifies
the class or activity where the log call occurs.msg
- The message you would like logged.tr
- An exception to logpublic static int w(java.lang.String tag, java.lang.String msg)
WARN
log message.
tag
- Used to identify the source of a log message. It usually identifies
the class or activity where the log call occurs.msg
- The message you would like logged.public static int w(java.lang.String tag, java.lang.String msg, java.lang.Throwable tr)
WARN
log message and log the exception.
tag
- Used to identify the source of a log message. It usually identifies
the class or activity where the log call occurs.msg
- The message you would like logged.tr
- An exception to logpublic static boolean isLoggable(java.lang.String tag, int level)
tag
- The tag to check.level
- The level to check.
java.lang.IllegalArgumentException
- is thrown if the tag.length() > 23.public static int w(java.lang.String tag, java.lang.Throwable tr)
public static int e(java.lang.String tag, java.lang.String msg)
ERROR
log message.
tag
- Used to identify the source of a log message. It usually identifies
the class or activity where the log call occurs.msg
- The message you would like logged.public static int e(java.lang.String tag, java.lang.String msg, java.lang.Throwable tr)
ERROR
log message and log the exception.
tag
- Used to identify the source of a log message. It usually identifies
the class or activity where the log call occurs.msg
- The message you would like logged.tr
- An exception to logpublic static java.lang.String getStackTraceString(java.lang.Throwable tr)
tr
- An exception to logpublic static int println(int priority, java.lang.String tag, java.lang.String msg)
priority
- The priority/type of this log messagetag
- Used to identify the source of a log message. It usually identifies
the class or activity where the log call occurs.msg
- The message you would like logged.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |