Loading include/log/logprint.h +11 −8 Original line number Diff line number Diff line Loading @@ -36,7 +36,9 @@ typedef enum { FORMAT_TIME, FORMAT_THREADTIME, FORMAT_LONG, FORMAT_COLOR, /* The following two are modifiers to above formats */ FORMAT_MODIFIER_COLOR, /* converts priority to color */ FORMAT_MODIFIER_TIME_USEC, /* switches from msec to usec time precision */ } AndroidLogPrintFormat; typedef struct AndroidLogFormat_t AndroidLogFormat; Loading @@ -56,7 +58,8 @@ AndroidLogFormat *android_log_format_new(); void android_log_format_free(AndroidLogFormat *p_format); void android_log_setPrintFormat(AndroidLogFormat *p_format, /* currently returns 0 if format is a modifier, 1 if not */ int android_log_setPrintFormat(AndroidLogFormat *p_format, AndroidLogPrintFormat format); /** Loading liblog/logprint.c +27 −12 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ struct AndroidLogFormat_t { FilterInfo *filters; AndroidLogPrintFormat format; bool colored_output; bool usec_time_output; }; /* Loading Loading @@ -185,6 +186,7 @@ AndroidLogFormat *android_log_format_new() p_ret->global_pri = ANDROID_LOG_VERBOSE; p_ret->format = FORMAT_BRIEF; p_ret->colored_output = false; p_ret->usec_time_output = false; return p_ret; } Loading @@ -207,13 +209,19 @@ void android_log_format_free(AndroidLogFormat *p_format) void android_log_setPrintFormat(AndroidLogFormat *p_format, int android_log_setPrintFormat(AndroidLogFormat *p_format, AndroidLogPrintFormat format) { if (format == FORMAT_COLOR) if (format == FORMAT_MODIFIER_COLOR) { p_format->colored_output = true; else return 0; } if (format == FORMAT_MODIFIER_TIME_USEC) { p_format->usec_time_output = true; return 0; } p_format->format = format; return 1; } /** Loading @@ -231,7 +239,8 @@ AndroidLogPrintFormat android_log_formatFromString(const char * formatString) else if (strcmp(formatString, "time") == 0) format = FORMAT_TIME; else if (strcmp(formatString, "threadtime") == 0) format = FORMAT_THREADTIME; else if (strcmp(formatString, "long") == 0) format = FORMAT_LONG; else if (strcmp(formatString, "color") == 0) format = FORMAT_COLOR; else if (strcmp(formatString, "color") == 0) format = FORMAT_MODIFIER_COLOR; else if (strcmp(formatString, "usec") == 0) format = FORMAT_MODIFIER_TIME_USEC; else format = FORMAT_OFF; return format; Loading Loading @@ -745,7 +754,7 @@ char *android_log_formatLogLine ( struct tm tmBuf; #endif struct tm* ptm; char timeBuf[32]; char timeBuf[32]; /* good margin, 23+nul for msec, 26+nul for usec */ char prefixBuf[128], suffixBuf[128]; char priChar; int prefixSuffixIsHeaderFooter = 0; Loading @@ -771,6 +780,14 @@ char *android_log_formatLogLine ( #endif //strftime(timeBuf, sizeof(timeBuf), "%Y-%m-%d %H:%M:%S", ptm); strftime(timeBuf, sizeof(timeBuf), "%m-%d %H:%M:%S", ptm); len = strlen(timeBuf); if (p_format->usec_time_output) { snprintf(timeBuf + len, sizeof(timeBuf) - len, ".%06ld", entry->tv_nsec / 1000); } else { snprintf(timeBuf + len, sizeof(timeBuf) - len, ".%03ld", entry->tv_nsec / 1000000); } /* * Construct a buffer containing the log header and log message. Loading Loading @@ -811,23 +828,21 @@ char *android_log_formatLogLine ( break; case FORMAT_TIME: len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen, "%s.%03ld %c/%-8s(%5d): ", timeBuf, entry->tv_nsec / 1000000, priChar, entry->tag, entry->pid); "%s %c/%-8s(%5d): ", timeBuf, priChar, entry->tag, entry->pid); strcpy(suffixBuf + suffixLen, "\n"); ++suffixLen; break; case FORMAT_THREADTIME: len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen, "%s.%03ld %5d %5d %c %-8s: ", timeBuf, entry->tv_nsec / 1000000, "%s %5d %5d %c %-8s: ", timeBuf, entry->pid, entry->tid, priChar, entry->tag); strcpy(suffixBuf + suffixLen, "\n"); ++suffixLen; break; case FORMAT_LONG: len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen, "[ %s.%03ld %5d:%5d %c/%-8s ]\n", timeBuf, entry->tv_nsec / 1000000, entry->pid, entry->tid, priChar, entry->tag); "[ %s %5d:%5d %c/%-8s ]\n", timeBuf, entry->pid, entry->tid, priChar, entry->tag); strcpy(suffixBuf + suffixLen, "\n\n"); suffixLen += 2; prefixSuffixIsHeaderFooter = 1; Loading logcat/logcat.cpp +3 −8 Original line number Diff line number Diff line Loading @@ -235,7 +235,7 @@ static void show_help(const char *cmd) " -r <kbytes> Rotate log every kbytes. Requires -f\n" " -n <count> Sets max number of rotated logs to <count>, default 4\n" " -v <format> Sets the log print format, where <format> is:\n\n" " brief color long process raw tag thread threadtime time\n\n" " brief color long process raw tag thread threadtime time usec\n\n" " -D print dividers between each log buffer\n" " -c clear (flush) the entire log and exit\n" " -d dump the log and then exit (don't block)\n" Loading Loading @@ -291,9 +291,7 @@ static int setLogFormat(const char * formatString) return -1; } android_log_setPrintFormat(g_logformat, format); return 0; return android_log_setPrintFormat(g_logformat, format); } static const char multipliers[][2] = { Loading Loading @@ -569,10 +567,7 @@ int main(int argc, char **argv) if (err < 0) { logcat_panic(true, "Invalid parameter %s to -v\n", optarg); } if (strcmp("color", optarg)) { // exception for modifiers hasSetLogFormat = 1; } hasSetLogFormat |= err; break; case 'Q': Loading logd/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ LOCAL_SRC_FILES := \ LogWhiteBlackList.cpp \ libaudit.c \ LogAudit.cpp \ LogKlog.cpp \ event.logtags LOCAL_SHARED_LIBRARIES := \ Loading logd/CommandListener.cpp +39 −40 Original line number Diff line number Diff line Loading @@ -33,9 +33,9 @@ #include "LogCommand.h" CommandListener::CommandListener(LogBuffer *buf, LogReader * /*reader*/, LogListener * /*swl*/) : FrameworkListener(getLogSocket()) , mBuf(*buf) { LogListener * /*swl*/) : FrameworkListener(getLogSocket()), mBuf(*buf) { // registerCmd(new ShutdownCmd(buf, writer, swl)); registerCmd(new ClearCmd(buf)); registerCmd(new GetBufSizeCmd(buf)); Loading @@ -48,12 +48,12 @@ CommandListener::CommandListener(LogBuffer *buf, LogReader * /*reader*/, } CommandListener::ShutdownCmd::ShutdownCmd(LogBuffer *buf, LogReader *reader, LogListener *swl) : LogCommand("shutdown") , mBuf(*buf) , mReader(*reader) , mSwl(*swl) { } LogListener *swl) : LogCommand("shutdown"), mBuf(*buf), mReader(*reader), mSwl(*swl) { } int CommandListener::ShutdownCmd::runCommand(SocketClient * /*cli*/, int /*argc*/, Loading @@ -63,10 +63,10 @@ int CommandListener::ShutdownCmd::runCommand(SocketClient * /*cli*/, exit(0); } CommandListener::ClearCmd::ClearCmd(LogBuffer *buf) : LogCommand("clear") , mBuf(*buf) { } CommandListener::ClearCmd::ClearCmd(LogBuffer *buf) : LogCommand("clear"), mBuf(*buf) { } static void setname() { static bool name_set; Loading Loading @@ -100,10 +100,10 @@ int CommandListener::ClearCmd::runCommand(SocketClient *cli, return 0; } CommandListener::GetBufSizeCmd::GetBufSizeCmd(LogBuffer *buf) : LogCommand("getLogSize") , mBuf(*buf) { } CommandListener::GetBufSizeCmd::GetBufSizeCmd(LogBuffer *buf) : LogCommand("getLogSize"), mBuf(*buf) { } int CommandListener::GetBufSizeCmd::runCommand(SocketClient *cli, int argc, char **argv) { Loading @@ -126,10 +126,10 @@ int CommandListener::GetBufSizeCmd::runCommand(SocketClient *cli, return 0; } CommandListener::SetBufSizeCmd::SetBufSizeCmd(LogBuffer *buf) : LogCommand("setLogSize") , mBuf(*buf) { } CommandListener::SetBufSizeCmd::SetBufSizeCmd(LogBuffer *buf) : LogCommand("setLogSize"), mBuf(*buf) { } int CommandListener::SetBufSizeCmd::runCommand(SocketClient *cli, int argc, char **argv) { Loading Loading @@ -160,10 +160,10 @@ int CommandListener::SetBufSizeCmd::runCommand(SocketClient *cli, return 0; } CommandListener::GetBufSizeUsedCmd::GetBufSizeUsedCmd(LogBuffer *buf) : LogCommand("getLogSizeUsed") , mBuf(*buf) { } CommandListener::GetBufSizeUsedCmd::GetBufSizeUsedCmd(LogBuffer *buf) : LogCommand("getLogSizeUsed"), mBuf(*buf) { } int CommandListener::GetBufSizeUsedCmd::runCommand(SocketClient *cli, int argc, char **argv) { Loading @@ -186,10 +186,10 @@ int CommandListener::GetBufSizeUsedCmd::runCommand(SocketClient *cli, return 0; } CommandListener::GetStatisticsCmd::GetStatisticsCmd(LogBuffer *buf) : LogCommand("getStatistics") , mBuf(*buf) { } CommandListener::GetStatisticsCmd::GetStatisticsCmd(LogBuffer *buf) : LogCommand("getStatistics"), mBuf(*buf) { } static void package_string(char **strp) { const char *a = *strp; Loading Loading @@ -243,10 +243,10 @@ int CommandListener::GetStatisticsCmd::runCommand(SocketClient *cli, return 0; } CommandListener::GetPruneListCmd::GetPruneListCmd(LogBuffer *buf) : LogCommand("getPruneList") , mBuf(*buf) { } CommandListener::GetPruneListCmd::GetPruneListCmd(LogBuffer *buf) : LogCommand("getPruneList"), mBuf(*buf) { } int CommandListener::GetPruneListCmd::runCommand(SocketClient *cli, int /*argc*/, char ** /*argv*/) { Loading @@ -263,10 +263,10 @@ int CommandListener::GetPruneListCmd::runCommand(SocketClient *cli, return 0; } CommandListener::SetPruneListCmd::SetPruneListCmd(LogBuffer *buf) : LogCommand("setPruneList") , mBuf(*buf) { } CommandListener::SetPruneListCmd::SetPruneListCmd(LogBuffer *buf) : LogCommand("setPruneList"), mBuf(*buf) { } int CommandListener::SetPruneListCmd::runCommand(SocketClient *cli, int argc, char **argv) { Loading Loading @@ -301,9 +301,8 @@ int CommandListener::SetPruneListCmd::runCommand(SocketClient *cli, return 0; } CommandListener::ReinitCmd::ReinitCmd() : LogCommand("reinit") { } CommandListener::ReinitCmd::ReinitCmd() : LogCommand("reinit") { } int CommandListener::ReinitCmd::runCommand(SocketClient *cli, int /*argc*/, char ** /*argv*/) { Loading Loading
include/log/logprint.h +11 −8 Original line number Diff line number Diff line Loading @@ -36,7 +36,9 @@ typedef enum { FORMAT_TIME, FORMAT_THREADTIME, FORMAT_LONG, FORMAT_COLOR, /* The following two are modifiers to above formats */ FORMAT_MODIFIER_COLOR, /* converts priority to color */ FORMAT_MODIFIER_TIME_USEC, /* switches from msec to usec time precision */ } AndroidLogPrintFormat; typedef struct AndroidLogFormat_t AndroidLogFormat; Loading @@ -56,7 +58,8 @@ AndroidLogFormat *android_log_format_new(); void android_log_format_free(AndroidLogFormat *p_format); void android_log_setPrintFormat(AndroidLogFormat *p_format, /* currently returns 0 if format is a modifier, 1 if not */ int android_log_setPrintFormat(AndroidLogFormat *p_format, AndroidLogPrintFormat format); /** Loading
liblog/logprint.c +27 −12 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ struct AndroidLogFormat_t { FilterInfo *filters; AndroidLogPrintFormat format; bool colored_output; bool usec_time_output; }; /* Loading Loading @@ -185,6 +186,7 @@ AndroidLogFormat *android_log_format_new() p_ret->global_pri = ANDROID_LOG_VERBOSE; p_ret->format = FORMAT_BRIEF; p_ret->colored_output = false; p_ret->usec_time_output = false; return p_ret; } Loading @@ -207,13 +209,19 @@ void android_log_format_free(AndroidLogFormat *p_format) void android_log_setPrintFormat(AndroidLogFormat *p_format, int android_log_setPrintFormat(AndroidLogFormat *p_format, AndroidLogPrintFormat format) { if (format == FORMAT_COLOR) if (format == FORMAT_MODIFIER_COLOR) { p_format->colored_output = true; else return 0; } if (format == FORMAT_MODIFIER_TIME_USEC) { p_format->usec_time_output = true; return 0; } p_format->format = format; return 1; } /** Loading @@ -231,7 +239,8 @@ AndroidLogPrintFormat android_log_formatFromString(const char * formatString) else if (strcmp(formatString, "time") == 0) format = FORMAT_TIME; else if (strcmp(formatString, "threadtime") == 0) format = FORMAT_THREADTIME; else if (strcmp(formatString, "long") == 0) format = FORMAT_LONG; else if (strcmp(formatString, "color") == 0) format = FORMAT_COLOR; else if (strcmp(formatString, "color") == 0) format = FORMAT_MODIFIER_COLOR; else if (strcmp(formatString, "usec") == 0) format = FORMAT_MODIFIER_TIME_USEC; else format = FORMAT_OFF; return format; Loading Loading @@ -745,7 +754,7 @@ char *android_log_formatLogLine ( struct tm tmBuf; #endif struct tm* ptm; char timeBuf[32]; char timeBuf[32]; /* good margin, 23+nul for msec, 26+nul for usec */ char prefixBuf[128], suffixBuf[128]; char priChar; int prefixSuffixIsHeaderFooter = 0; Loading @@ -771,6 +780,14 @@ char *android_log_formatLogLine ( #endif //strftime(timeBuf, sizeof(timeBuf), "%Y-%m-%d %H:%M:%S", ptm); strftime(timeBuf, sizeof(timeBuf), "%m-%d %H:%M:%S", ptm); len = strlen(timeBuf); if (p_format->usec_time_output) { snprintf(timeBuf + len, sizeof(timeBuf) - len, ".%06ld", entry->tv_nsec / 1000); } else { snprintf(timeBuf + len, sizeof(timeBuf) - len, ".%03ld", entry->tv_nsec / 1000000); } /* * Construct a buffer containing the log header and log message. Loading Loading @@ -811,23 +828,21 @@ char *android_log_formatLogLine ( break; case FORMAT_TIME: len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen, "%s.%03ld %c/%-8s(%5d): ", timeBuf, entry->tv_nsec / 1000000, priChar, entry->tag, entry->pid); "%s %c/%-8s(%5d): ", timeBuf, priChar, entry->tag, entry->pid); strcpy(suffixBuf + suffixLen, "\n"); ++suffixLen; break; case FORMAT_THREADTIME: len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen, "%s.%03ld %5d %5d %c %-8s: ", timeBuf, entry->tv_nsec / 1000000, "%s %5d %5d %c %-8s: ", timeBuf, entry->pid, entry->tid, priChar, entry->tag); strcpy(suffixBuf + suffixLen, "\n"); ++suffixLen; break; case FORMAT_LONG: len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen, "[ %s.%03ld %5d:%5d %c/%-8s ]\n", timeBuf, entry->tv_nsec / 1000000, entry->pid, entry->tid, priChar, entry->tag); "[ %s %5d:%5d %c/%-8s ]\n", timeBuf, entry->pid, entry->tid, priChar, entry->tag); strcpy(suffixBuf + suffixLen, "\n\n"); suffixLen += 2; prefixSuffixIsHeaderFooter = 1; Loading
logcat/logcat.cpp +3 −8 Original line number Diff line number Diff line Loading @@ -235,7 +235,7 @@ static void show_help(const char *cmd) " -r <kbytes> Rotate log every kbytes. Requires -f\n" " -n <count> Sets max number of rotated logs to <count>, default 4\n" " -v <format> Sets the log print format, where <format> is:\n\n" " brief color long process raw tag thread threadtime time\n\n" " brief color long process raw tag thread threadtime time usec\n\n" " -D print dividers between each log buffer\n" " -c clear (flush) the entire log and exit\n" " -d dump the log and then exit (don't block)\n" Loading Loading @@ -291,9 +291,7 @@ static int setLogFormat(const char * formatString) return -1; } android_log_setPrintFormat(g_logformat, format); return 0; return android_log_setPrintFormat(g_logformat, format); } static const char multipliers[][2] = { Loading Loading @@ -569,10 +567,7 @@ int main(int argc, char **argv) if (err < 0) { logcat_panic(true, "Invalid parameter %s to -v\n", optarg); } if (strcmp("color", optarg)) { // exception for modifiers hasSetLogFormat = 1; } hasSetLogFormat |= err; break; case 'Q': Loading
logd/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ LOCAL_SRC_FILES := \ LogWhiteBlackList.cpp \ libaudit.c \ LogAudit.cpp \ LogKlog.cpp \ event.logtags LOCAL_SHARED_LIBRARIES := \ Loading
logd/CommandListener.cpp +39 −40 Original line number Diff line number Diff line Loading @@ -33,9 +33,9 @@ #include "LogCommand.h" CommandListener::CommandListener(LogBuffer *buf, LogReader * /*reader*/, LogListener * /*swl*/) : FrameworkListener(getLogSocket()) , mBuf(*buf) { LogListener * /*swl*/) : FrameworkListener(getLogSocket()), mBuf(*buf) { // registerCmd(new ShutdownCmd(buf, writer, swl)); registerCmd(new ClearCmd(buf)); registerCmd(new GetBufSizeCmd(buf)); Loading @@ -48,12 +48,12 @@ CommandListener::CommandListener(LogBuffer *buf, LogReader * /*reader*/, } CommandListener::ShutdownCmd::ShutdownCmd(LogBuffer *buf, LogReader *reader, LogListener *swl) : LogCommand("shutdown") , mBuf(*buf) , mReader(*reader) , mSwl(*swl) { } LogListener *swl) : LogCommand("shutdown"), mBuf(*buf), mReader(*reader), mSwl(*swl) { } int CommandListener::ShutdownCmd::runCommand(SocketClient * /*cli*/, int /*argc*/, Loading @@ -63,10 +63,10 @@ int CommandListener::ShutdownCmd::runCommand(SocketClient * /*cli*/, exit(0); } CommandListener::ClearCmd::ClearCmd(LogBuffer *buf) : LogCommand("clear") , mBuf(*buf) { } CommandListener::ClearCmd::ClearCmd(LogBuffer *buf) : LogCommand("clear"), mBuf(*buf) { } static void setname() { static bool name_set; Loading Loading @@ -100,10 +100,10 @@ int CommandListener::ClearCmd::runCommand(SocketClient *cli, return 0; } CommandListener::GetBufSizeCmd::GetBufSizeCmd(LogBuffer *buf) : LogCommand("getLogSize") , mBuf(*buf) { } CommandListener::GetBufSizeCmd::GetBufSizeCmd(LogBuffer *buf) : LogCommand("getLogSize"), mBuf(*buf) { } int CommandListener::GetBufSizeCmd::runCommand(SocketClient *cli, int argc, char **argv) { Loading @@ -126,10 +126,10 @@ int CommandListener::GetBufSizeCmd::runCommand(SocketClient *cli, return 0; } CommandListener::SetBufSizeCmd::SetBufSizeCmd(LogBuffer *buf) : LogCommand("setLogSize") , mBuf(*buf) { } CommandListener::SetBufSizeCmd::SetBufSizeCmd(LogBuffer *buf) : LogCommand("setLogSize"), mBuf(*buf) { } int CommandListener::SetBufSizeCmd::runCommand(SocketClient *cli, int argc, char **argv) { Loading Loading @@ -160,10 +160,10 @@ int CommandListener::SetBufSizeCmd::runCommand(SocketClient *cli, return 0; } CommandListener::GetBufSizeUsedCmd::GetBufSizeUsedCmd(LogBuffer *buf) : LogCommand("getLogSizeUsed") , mBuf(*buf) { } CommandListener::GetBufSizeUsedCmd::GetBufSizeUsedCmd(LogBuffer *buf) : LogCommand("getLogSizeUsed"), mBuf(*buf) { } int CommandListener::GetBufSizeUsedCmd::runCommand(SocketClient *cli, int argc, char **argv) { Loading @@ -186,10 +186,10 @@ int CommandListener::GetBufSizeUsedCmd::runCommand(SocketClient *cli, return 0; } CommandListener::GetStatisticsCmd::GetStatisticsCmd(LogBuffer *buf) : LogCommand("getStatistics") , mBuf(*buf) { } CommandListener::GetStatisticsCmd::GetStatisticsCmd(LogBuffer *buf) : LogCommand("getStatistics"), mBuf(*buf) { } static void package_string(char **strp) { const char *a = *strp; Loading Loading @@ -243,10 +243,10 @@ int CommandListener::GetStatisticsCmd::runCommand(SocketClient *cli, return 0; } CommandListener::GetPruneListCmd::GetPruneListCmd(LogBuffer *buf) : LogCommand("getPruneList") , mBuf(*buf) { } CommandListener::GetPruneListCmd::GetPruneListCmd(LogBuffer *buf) : LogCommand("getPruneList"), mBuf(*buf) { } int CommandListener::GetPruneListCmd::runCommand(SocketClient *cli, int /*argc*/, char ** /*argv*/) { Loading @@ -263,10 +263,10 @@ int CommandListener::GetPruneListCmd::runCommand(SocketClient *cli, return 0; } CommandListener::SetPruneListCmd::SetPruneListCmd(LogBuffer *buf) : LogCommand("setPruneList") , mBuf(*buf) { } CommandListener::SetPruneListCmd::SetPruneListCmd(LogBuffer *buf) : LogCommand("setPruneList"), mBuf(*buf) { } int CommandListener::SetPruneListCmd::runCommand(SocketClient *cli, int argc, char **argv) { Loading Loading @@ -301,9 +301,8 @@ int CommandListener::SetPruneListCmd::runCommand(SocketClient *cli, return 0; } CommandListener::ReinitCmd::ReinitCmd() : LogCommand("reinit") { } CommandListener::ReinitCmd::ReinitCmd() : LogCommand("reinit") { } int CommandListener::ReinitCmd::runCommand(SocketClient *cli, int /*argc*/, char ** /*argv*/) { Loading