FileDocCategorySizeDatePackage
EventLog.javaAPI DocAndroid 1.5 API10137Wed May 06 22:41:56 BST 2009android.util

EventLog

public class EventLog extends Object
{@hide} Dynamically defined (in terms of event types), space efficient (i.e. "tight") event logging to help instrument code for large scale stability and performance monitoring. Note that this class contains all static methods. This is done for efficiency reasons. Events for the event log are self-describing binary data structures. They start with a 20 byte header (generated automatically) which contains all of the following in order:
  • Payload length: 2 bytes - length of the non-header portion
  • Padding: 2 bytes - no meaning at this time
  • Timestamp:
    • Seconds: 4 bytes - seconds since Epoch
    • Nanoseconds: 4 bytes - plus extra nanoseconds
  • Process ID: 4 bytes - matching {@link android.os.Process#myPid}
  • Thread ID: 4 bytes - matching {@link android.os.Process#myTid}
The above is followed by a payload, comprised of the following:
  • Tag: 4 bytes - unique integer used to identify a particular event. This number is also used as a key to map to a string that can be displayed by log reading tools.
  • Type: 1 byte - can be either {@link #INT}, {@link #LONG}, {@link #STRING}, or {@link #LIST}.
  • Event log value: the size and format of which is one of:
    • INT: 4 bytes
    • LONG: 8 bytes
    • STRING:
      • Size of STRING: 4 bytes
      • The string: n bytes as specified in the size fields above.
    • {@link List LIST}:
      • Num items: 1 byte
      • N value payloads, where N is the number of items specified above.
  • '\n': 1 byte - an automatically generated newline, used to help detect and recover from log corruption and enable stansard unix tools like grep, tail and wc to operate on event logs.
Note that all output is done in the endian-ness of the device (as determined by {@link ByteOrder#nativeOrder()}).

Fields Summary
public static final byte
INT
public static final byte
LONG
public static final byte
STRING
public static final byte
LIST
Constructors Summary
Methods Summary
public static native voidreadEvents(int[] tags, java.util.Collection output)
Read events from the log, filtered by type.

param
tags to search for
param
output container to add events into
throws
IOException if something goes wrong reading events

public static native intwriteEvent(int tag, int value)
Send an event log message.

param
tag An event identifer
param
value A value to log
return
The number of bytes written

public static native intwriteEvent(int tag, long value)
Send an event log message.

param
tag An event identifer
param
value A value to log
return
The number of bytes written

public static native intwriteEvent(int tag, java.lang.String str)
Send an event log message.

param
tag An event identifer
param
str A value to log
return
The number of bytes written

public static native intwriteEvent(int tag, android.util.EventLog$List list)
Send an event log message.

param
tag An event identifer
param
list A {@link List} to log
return
The number of bytes written

public static intwriteEvent(int tag, java.lang.Object list)
Send an event log message.

param
tag An event identifer
param
list A list of values to log
return
The number of bytes written

        return writeEvent(tag, new List(list));