Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0c6c4150 authored by Mark Salyzyn's avatar Mark Salyzyn Committed by Gerrit Code Review
Browse files

Merge changes I2cda9dd7,Ifb560850,I8d4c7c5a

* changes:
  logd: Cleanup
  logcat: liblog: Add "usec" format argument
  logd: Add klogd
parents 74f0a578 77187787
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -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;
@@ -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);

/**
+27 −12
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ struct AndroidLogFormat_t {
    FilterInfo *filters;
    AndroidLogPrintFormat format;
    bool colored_output;
    bool usec_time_output;
};

/*
@@ -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;
}
@@ -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;
}

/**
@@ -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;
@@ -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;
@@ -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.
@@ -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;
+3 −8
Original line number Diff line number Diff line
@@ -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"
@@ -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] = {
@@ -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':
+1 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ LOCAL_SRC_FILES := \
    LogWhiteBlackList.cpp \
    libaudit.c \
    LogAudit.cpp \
    LogKlog.cpp \
    event.logtags

LOCAL_SHARED_LIBRARIES := \
+39 −40
Original line number Diff line number Diff line
@@ -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));
@@ -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*/,
@@ -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;
@@ -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) {
@@ -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) {
@@ -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) {
@@ -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;
@@ -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*/) {
@@ -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) {
@@ -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