Android logger

Here is some information on the Android logger:

Overview
General system-wide logging is supported by a kernel device driver call 'logger'. The code for the driver is in 'drivers/staging/android/logger.c' in recent android versions but in 'drivers/misc/logger.c' in older versions and in 'drivers/android/logger.c' in old  ones

The code supports 4 logging buffers, named "main", "events", "radio", and "system" for different types of events.

Driver Features
Log reading and writing is done via normal Linux file reads and writes.

The write path is optimized, so that an open, write, close sequence can occur very quickly, to avoid logging having too much overhead in the system.

Reading
From user-space, a normal 'read' operation is used to read an entry from the log. Each read returns one log entry, or blocks waiting for the next entry. The device can be opened in non-blocking mode.

At least LOGGER_ENTRY_MAX_LEN (4096) should be used as the amount of data to read from the log on a read request.

Writing
The system performs writes to the log. The driver saves the pid, tgid and timestamp for each log entry. It appears that the level, tag and message are provided by user-space.

ioctls
The following ioctl's are supported, which pretty much do what you would expect:
 * LOGGER_GET_LOG_BUF_SIZE - returns the size of the entire log buffer
 * LOGGER_GET_LOG_LEN - returns the amount of data in the log
 * LOGGER_GET_NEXT_ENTRY_LEN - returns size of next log entry
 * LOGGER_FLUSH_LOG - clears the log of data

Device Nodes
The driver is activated when a user-space program opens a device node with the appropriate major and minor number.

These nodes are located in /dev/log, as shown below: crw-rw--w-   1 0        1007      10,  50 Nov  5 02:00 events crw-rw--w-   1 0        1007      10,  51 Nov  5 02:00 main crw-rw--w-   1 0        1007      10,  49 Nov  5 02:00 radio
 * 1) ls -l /dev/log

/dev/log/system was added in Feb, 2010

Android Logging System
See Android Logging System for information about the complete android logging system, including tools which access this driver.