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

Commit ad7287d1 authored by Diogo Ferreira's avatar Diogo Ferreira Committed by Ricardo Cerqueira
Browse files

liblog: Forward xlog to regular android buffers on demand

This may be useful when dealing with proprietary blobs like video
where they spit a ton of useful debug information through xlog.

Also, bring it up if MTKLogger is active

Change-Id: I67bc397bfa935aa0716502f949fc7ab6c6b1dfd3
parent 92d5ea9c
Loading
Loading
Loading
Loading
+42 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@
#include <android/set_abort_message.h>
#endif

#ifdef MOTOROLA_LOG
#if defined(MOTOROLA_LOG) || defined(MTK_HARDWARE)
#if HAVE_LIBC_SYSTEM_PROPERTIES
#include <sys/system_properties.h>
#endif
@@ -609,3 +609,44 @@ int __android_log_bswrite(int32_t tag, const char *payload)

    return write_to_log(LOG_ID_EVENTS, vec, 4);
}

#ifdef MTK_HARDWARE
struct xlog_record {
    const char *tag_str;
    const char *fmt_str;
    int prio;
};

void __attribute__((weak)) __xlog_buf_printf(int bufid, const struct xlog_record *xlog_record, ...) {
    va_list args;
    va_start(args, xlog_record);
#if    HAVE_LIBC_SYSTEM_PROPERTIES
    int len = 0;
    int do_xlog = 0;
    char results[PROP_VALUE_MAX];


    // MobileLog
    len = __system_property_get ("debug.MB.running", results);
    if (len && atoi(results))
        do_xlog = 1;

    // ModemLog
    len = __system_property_get ("debug.mdlogger.Running", results);
    if (len && atoi(results))
        do_xlog = 1;

    // Manual
    len = __system_property_get ("persist.debug.xlog.enable", results);
    if (len && atoi(results))
        do_xlog = 1;

    if (do_xlog > 0)
#endif
        __android_log_vprint(xlog_record->prio, xlog_record->tag_str, xlog_record->fmt_str, args);

    // get rid of "unused parameter 'bufid'"
    bufid = bufid;
    return;
}
#endif