Merge "Use standard colors in logcat color output"
This commit is contained in:
commit
7382be402a
2 changed files with 18 additions and 15 deletions
|
|
@ -78,18 +78,21 @@ struct AndroidLogFormat_t {
|
||||||
static bool descriptive_output = false;
|
static bool descriptive_output = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* gnome-terminal color tags
|
* 8-bit color tags. See ECMA-48 Set Graphics Rendition in
|
||||||
* See http://misc.flogisoft.com/bash/tip_colors_and_formatting
|
* [console_codes(4)](https://man7.org/linux/man-pages/man4/console_codes.4.html).
|
||||||
* for ideas on how to set the forground color of the text for xterm.
|
*
|
||||||
* The color manipulation character stream is defined as:
|
* The text manipulation character stream is defined as:
|
||||||
* ESC [ 3 8 ; 5 ; <color#> m
|
* ESC [ <parameter #> m
|
||||||
|
*
|
||||||
|
* We use "set <color> foreground" escape sequences instead of
|
||||||
|
* "256/24-bit foreground color". This allows colors to render
|
||||||
|
* according to user preferences in terminal emulator settings
|
||||||
*/
|
*/
|
||||||
#define ANDROID_COLOR_BLUE 75
|
#define ANDROID_COLOR_BLUE 34
|
||||||
#define ANDROID_COLOR_DEFAULT 231
|
#define ANDROID_COLOR_DEFAULT 39
|
||||||
#define ANDROID_COLOR_GREEN 40
|
#define ANDROID_COLOR_GREEN 32
|
||||||
#define ANDROID_COLOR_ORANGE 166
|
#define ANDROID_COLOR_RED 31
|
||||||
#define ANDROID_COLOR_RED 196
|
#define ANDROID_COLOR_YELLOW 33
|
||||||
#define ANDROID_COLOR_YELLOW 226
|
|
||||||
|
|
||||||
static FilterInfo* filterinfo_new(const char* tag, android_LogPriority pri) {
|
static FilterInfo* filterinfo_new(const char* tag, android_LogPriority pri) {
|
||||||
FilterInfo* p_ret;
|
FilterInfo* p_ret;
|
||||||
|
|
@ -165,7 +168,7 @@ static int colorFromPri(android_LogPriority pri) {
|
||||||
case ANDROID_LOG_VERBOSE: return ANDROID_COLOR_DEFAULT;
|
case ANDROID_LOG_VERBOSE: return ANDROID_COLOR_DEFAULT;
|
||||||
case ANDROID_LOG_DEBUG: return ANDROID_COLOR_BLUE;
|
case ANDROID_LOG_DEBUG: return ANDROID_COLOR_BLUE;
|
||||||
case ANDROID_LOG_INFO: return ANDROID_COLOR_GREEN;
|
case ANDROID_LOG_INFO: return ANDROID_COLOR_GREEN;
|
||||||
case ANDROID_LOG_WARN: return ANDROID_COLOR_ORANGE;
|
case ANDROID_LOG_WARN: return ANDROID_COLOR_YELLOW;
|
||||||
case ANDROID_LOG_ERROR: return ANDROID_COLOR_RED;
|
case ANDROID_LOG_ERROR: return ANDROID_COLOR_RED;
|
||||||
case ANDROID_LOG_FATAL: return ANDROID_COLOR_RED;
|
case ANDROID_LOG_FATAL: return ANDROID_COLOR_RED;
|
||||||
case ANDROID_LOG_SILENT: return ANDROID_COLOR_DEFAULT;
|
case ANDROID_LOG_SILENT: return ANDROID_COLOR_DEFAULT;
|
||||||
|
|
@ -1499,7 +1502,7 @@ char* android_log_formatLogLine(AndroidLogFormat* p_format, char* defaultBuffer,
|
||||||
*/
|
*/
|
||||||
if (p_format->colored_output) {
|
if (p_format->colored_output) {
|
||||||
prefixLen =
|
prefixLen =
|
||||||
snprintf(prefixBuf, sizeof(prefixBuf), "\x1B[38;5;%dm", colorFromPri(entry->priority));
|
snprintf(prefixBuf, sizeof(prefixBuf), "\x1B[%dm", colorFromPri(entry->priority));
|
||||||
prefixLen = MIN(prefixLen, sizeof(prefixBuf));
|
prefixLen = MIN(prefixLen, sizeof(prefixBuf));
|
||||||
|
|
||||||
const char suffixContents[] = "\x1B[0m";
|
const char suffixContents[] = "\x1B[0m";
|
||||||
|
|
|
||||||
|
|
@ -402,8 +402,8 @@ static void show_format_help() {
|
||||||
" time — Display the date, invocation time, priority/tag, and PID of the\n"
|
" time — Display the date, invocation time, priority/tag, and PID of the\n"
|
||||||
" process issuing the message.\n"
|
" process issuing the message.\n"
|
||||||
"\nAdverb modifiers can be used in combination:\n"
|
"\nAdverb modifiers can be used in combination:\n"
|
||||||
" color — Display in highlighted color to match priority. i.e. \x1B[38;5;231mVERBOSE\n"
|
" color — Display in highlighted color to match priority. i.e. \x1B[39mVERBOSE\n"
|
||||||
" \x1B[38;5;75mDEBUG \x1B[38;5;40mINFO \x1B[38;5;166mWARNING \x1B[38;5;196mERROR FATAL\x1B[0m\n"
|
" \x1B[34mDEBUG \x1B[32mINFO \x1B[33mWARNING \x1B[31mERROR FATAL\x1B[0m\n"
|
||||||
" descriptive — events logs only, descriptions from event-log-tags database.\n"
|
" descriptive — events logs only, descriptions from event-log-tags database.\n"
|
||||||
" epoch — Display time as seconds since Jan 1 1970.\n"
|
" epoch — Display time as seconds since Jan 1 1970.\n"
|
||||||
" monotonic — Display time as cpu seconds since last boot.\n"
|
" monotonic — Display time as cpu seconds since last boot.\n"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue