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

Commit 796e61c2 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Log the last error code of StatsLog failures"

parents 958a669e 1d35761c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ extern "C" {
#endif
void reset_log_context(android_log_context ctx);
int write_to_logger(android_log_context context, log_id_t id);
void note_log_drop();
void note_log_drop(int error);
void stats_log_close();
int android_log_write_char_array(android_log_context ctx, const char* value, size_t len);
#ifdef __cplusplus
+2 −2
Original line number Diff line number Diff line
@@ -120,8 +120,8 @@ int write_to_logger(android_log_context ctx, log_id_t id) {
    return retValue;
}

void note_log_drop() {
    statsdLoggerWrite.noteDrop();
void note_log_drop(int error) {
    statsdLoggerWrite.noteDrop(error);
}

void stats_log_close() {
+5 −2
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@

static pthread_mutex_t log_init_lock = PTHREAD_MUTEX_INITIALIZER;
static atomic_int dropped = 0;
static atomic_int log_error = 0;

void statsd_writer_init_lock() {
    /*
@@ -150,8 +151,9 @@ static int statsdAvailable() {
    return 1;
}

static void statsdNoteDrop() {
static void statsdNoteDrop(int error) {
    atomic_fetch_add_explicit(&dropped, 1, memory_order_relaxed);
    atomic_exchange_explicit(&log_error, error, memory_order_relaxed);
}

static int statsdWrite(struct timespec* ts, struct iovec* vec, size_t nr) {
@@ -202,7 +204,8 @@ static int statsdWrite(struct timespec* ts, struct iovec* vec, size_t nr) {
        if (snapshot) {
            android_log_event_int_t buffer;
            header.id = LOG_ID_STATS;
            buffer.header.tag = htole32(LIBLOG_LOG_TAG);
            // store the last log error in the tag field. This tag field is not used by statsd.
            buffer.header.tag = htole32(atomic_load(&log_error));
            buffer.payload.type = EVENT_TYPE_INT;
            buffer.payload.data = htole32(snapshot);

+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ struct android_log_transport_write {
    /* write log to transport, returns number of bytes propagated, or -errno */
    int (*write)(struct timespec* ts, struct iovec* vec, size_t nr);
    /* note one log drop */
    void (*noteDrop)();
    void (*noteDrop)(int error);
};

#endif  // ANDROID_STATS_LOG_STATS_WRITER_H