How does Android determine which buffer to use for logcat messages?

By standard, the Android system logcathas 4 different buffers:

main
system
radio
events

# and alias & groups:
all      -- all available logs
default  -- main
crash    -- n/a

However, on AOS 6+, there seem to be other buffers:

# logcat --help
...
  -b <buffer>     Request alternate ring buffer, 'main', 'system', 'radio',
                  'events', 'crash' or 'all'. Multiple -b parameters are
                  allowed and results are interleaved. The default is
                  -b main -b system -b crash.
...

and the android source code logcat.cpp , it seems there are still others, such as:

security 
kernel

Usually in the java-application method of placing messages in mainlogcat - is: Log.i(TAG, msg).

So the question is: How does Android determine which buffer to use for various logcat messages?

(Of particular note are specific links to the AOS source code).

Then the following natural question arises: how can you see or activate other hidden buffers?

+4
1

, , .

-, (Java) : platform_frameworks_base/core/java/android/util/ : platform_frameworks_base//java/android//.

EventLog.java   # EVENT Log:  These diagnostic events are for system integrators, not application authors.
Log.java        # MAIN Log:   Where user app logcat goes from:  Log.v() Log.d() Log.i() Log.w() and Log.e()
Slog.java       # SYSTEM Log: Primarily for use by coding running within the system process.
Rlog.java       # RADIO Log:  All radio, wifi, bluetooth etc. related logs. Also scrubs personal info from appearing in logs. 

:

EventLogTags.java       # Deprecated! (Use EventLog)
LocalLog.java           # log(), dump(), reverseDump(), ReadOnlyLocalLog()
LogPrinter.java         #  decides what buffer to print to: LOG_ID_<buffer_name>
LogWriter.java          #  decides priority and TAG
TimingLogger.java       # A utility class to help log timings splits throughout a method call.

Log.java:

public static final int LOG_ID_MAIN = 0;
public static final int LOG_ID_RADIO = 1;
public static final int LOG_ID_EVENTS = 2;
public static final int LOG_ID_SYSTEM = 3;
public static final int LOG_ID_CRASH = 4;

:

setprop log.tag.<YOUR_LOG_TAG> <LEVEL>

/data/local.prop:

log.tag.<YOUR_LOG_TAG>=<LEVEL>

, .

MAIN:

, , WARN, INFO, DEBUG, VERBOSE. , . . , .

: , ,

Log.v(TAG, "index=" + i);

, Log.d, StringBuilder : StringBuilder , String. , gc. , , .

EVENT:

. ( , , ), .

logcat ({@link android.util.Log})! , .

, /system/etc/event -log-tags. int, long String. event-log-tags .

+4

Source: https://habr.com/ru/post/1666014/


All Articles