Title: Theory / Unimportant / CS / Development / Android / Logcat
On every note of this deck, unless a note says otherwise:
Page: https://developer.android.com/studio/command-line/logcat
Page: https://developer.android.com/studio/command-line/logcat
Prefix: logcat
Context: adb

Instruction: logcat
Page: https://developer.android.com/studio/command-line
Effect: This is a tool invoked via adb to view app and system logs.
Context: android

Name: logd
Definition: System processin android log
Page: https://developer.android.com/studio/command-line/logcat

Question: how do android deals with log
Answer: in circular buffer maintained by logd
Page: https://developer.android.com/studio/command-line/logcat

Variable: main
Meaning: stores most application logs
Context: Android log

Variable: system
Meaning: stores messages originating from the Android OS
Context: Android log

Variable: crash
Meaning: stores crash log
Context: Android log

Name: A log
Definition: A priority
Page: https://developer.android.com/studio/command-line/logcat
Context: Android log
Definition2: a tag identifying the origin of the log
Definition3: a log message

Question: How are displayed log filtered
Answer: Compile-time filtering: depending on compilation settings, some logs may be completely removed from the binary. For example, Proguard can be configured to remove calls to Log.d from Java code.
Page: https://developer.android.com/studio/command-line/logcat
Context: Android log
Answer2: 1. System property filtering: liblog queries a set of system properties to determine the minimum severity level to be sent to logd. If your logs have the tag MyApp, the following properties are checked, and are expected to contain the first letter of the minimum severity (V, D, I, W, E, or S to disable all logs):
  - log.tag.MyApp
  - persist.log.tag.MyApp
  - log.tag
  - persist.log.tag
Answer3: Application filtering: If none of the properties are set, liblog uses the minimum priority set by __android_log_set_minimum_priority. The default setting is INFO.
Answer4: Display filtering: adb logcat supports additional filters that can reduce the amount of logs shown from logd. See below for details.
Name: A log

Page: https://developer.android.com/studio/command-line/logcat
Syntactic sugar: adb logcat
Implementation: adb shell logcat
Context: Android log

Fla: --help
Effect: display help

Fla: -b buffer
Effect: Load an alternate log buffer for viewing, such as events or radio.
Default: main, system, and crash

Fla: --clear
Effect: (flush) the selected buffers and exit
Flag abbreviation: -c

Fla: --regex=<expr>
Effect: Only print lines where the log message matches <expr>
Flag abbreviation: -e <expr>

Fla: --max-count=<count>
Effect: Quit after printing <count> number of lines.
Flag abbreviation: -m <count>

Fla: --print
Effect: Paired with --regex and --max-count to let content bypass the regex filter, but still stop at the right number of matches.

Fla: -d
Effect: Dump the log to the screen and exits.

Fla: -f filename
Effect: Write log message output to <filename>. The default is stdout.

Fla: --buffer-size
Flag abbreviation: -g
Print: the size of the specified log buffer and exits.

Fla: -n count
Effect: Set the maximum number of rotated logs to <count>.
Assuming: -r
Default: 4

Fla: -r kbytes
Effect: Rotate the log file every <kbytes> of output.
Assuming: requires the -f option
Default: 16

Fla: -s
Effect: Equivalent to the filter expression '*:S', which sets priority for all tags to silent, and is used to precede a list of filter expressions that add content.

Fla: --dividers
Effect: Print dividers between each log buffer.
Flag abbreviation: -D

Fla: -c
Effect: Flush (clear) the entire log and exit

Fla: -T count
Effect: print only the most recent number of lines.

Fla: -T '<time>'
Effect: Print the most recent lines since the specified time

Fla: -t
Effect: same as -dT

Fla: --last
Effect: Dump the logs prior to the last reboot.
Flag abbreviation: -L

Fla: --binary
Effect: Output the logs in binary
Flag abbreviation: -B

Fla: --statistics
Effect: include statistics in the output to help you identify and target log spammers
Flag abbreviation: -S

Fla: -G size
Effect: Set the size of the log ring buffer

Fla: -p
Effect: print the current allow and deny lists and takes no argument
Flag abbreviation: --prune

Fla: -p withargs
Effect: todo
Flag abbreviation: --prune

Fla: --pid=<pid>
Effect: Only print logs from the given PID

Fla: --wrap
Effect: Sleep for 2 hours or when the buffer is about to wrap whichever comes first.
Intuition: Improves efficiency of polling by providing an about-to-wrap wakeup.

Fla: -v brief
Effect: Display priority, tag, and PID of the process issuing the message.

Fla: -v long
Effect: Display all metadata fields and separate messages with blank lines.

Fla: -v process
Effect: Display PID only

Fla: -v raw
Print: the raw log message with no other metadata fields.

Fla: -v tag
Print: the priority and tag only

Fla: -v thread
Print: A legacy format that shows priority, PID, and TID of the thread issuing the message.

Fla: -v threadtime
Print: Display the date, invocation time, priority, tag, PID, and TID of the thread issuing the message.
Extra: It's the default

Fla: -v time
Print: Display the date, invocation time, priority, tag, and PID of the process issuing the message.

Variable: radio
Meaning: buffer that contains radio/telephony related messages.
Context: android log

Variable: events
Meaning: the interpreted binary system event buffer messages.
Context: android log