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

Commit 71002885 authored by Mark Salyzyn's avatar Mark Salyzyn
Browse files

liblog: add local_logger

- Create the local-only logger module
- Add LOGGER_LOCAL flag to android_set_log_frontend to enable
- Permit log reader for host compilation

android_set_log_frontend(LOGGER_LOCAL) will result in logs going
into application local memory.  logcat can not retrieve the data,
the user must utilize the log reading interface directly to
acquire their own logs.  Some local logger tests dropped as they
represent testing other liblog facilities.  Other local logger
tests dropped because we make the conscious decision to not
support LOG_ID_SECURITY logging.

ToDo: Some local logger tests dropped because of missing
      functionality associated with blocking reader.

Test: gTest libcutils-tests, logd-unit-tests, liblog-unit-tests,
      logcat-unit-tests, liblog-benchmarks and CtsLiblogTestCases_list
Bug: 27405083
Change-Id: Ia23b932af9e05756eaa60bab9139876b14faf72d
parent 96432fc6
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -15,12 +15,15 @@
//

liblog_sources = [
    "config_read.c",
    "config_write.c",
    "local_logger.c",
    "log_event_list.c",
    "log_event_write.c",
    "log_ratelimit.cpp",
    "logger_lock.c",
    "logger_name.c",
    "logger_read.c",
    "logger_write.c",
    "logprint.c",
]
@@ -30,14 +33,12 @@ liblog_host_sources = [
]
liblog_target_sources = [
    "event_tag_map.cpp",
    "config_read.c",
    "log_time.cpp",
    "properties.c",
    "pmsg_reader.c",
    "pmsg_writer.c",
    "logd_reader.c",
    "logd_writer.c",
    "logger_read.c",
]

// Shared and static library for host and device
+4 −3
Original line number Diff line number Diff line
@@ -168,8 +168,9 @@ DESCRIPTION
       ANDROID_LOG_RDONLY in these cases.

       android_set_log_frontend() selects frontend filters. Argument is either
       LOGGER_DEFAULT,  LOGGER_LOGD  or  LOGGER_NULL.  The  latter  drops  all
       content   on   the   floor.     Both   android_set_log_frontend()   and
       LOGGER_DEFAULT, LOGGER_LOGD, LOGGER_NULL or LOGGER_LOCAL. Log to logger
       daemon for default or logd,  drop contents on floor,  or log into local
       memory   respectively.          Both   android_set_log_frontend()   and
       android_get_log_frontend()  return  the  current  frontend mask,   or a
       negative errno for any problems.

+18 −4
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@
 * limitations under the License.
 */

#include <log/log_frontend.h>

#include "config_read.h"
#include "logger.h"

@@ -52,12 +54,24 @@ static void __android_log_add_transport(
}

LIBLOG_HIDDEN void __android_log_config_read() {
    if (__android_log_frontend & LOGGER_LOCAL) {
        extern struct android_log_transport_read localLoggerRead;

        __android_log_add_transport(&__android_log_transport_read,
                                    &localLoggerRead);
    }

#if (FAKE_LOG_DEVICE == 0)
    if ((__android_log_frontend == LOGGER_DEFAULT) ||
        (__android_log_frontend & LOGGER_LOGD)) {
        extern struct android_log_transport_read logdLoggerRead;
        extern struct android_log_transport_read pmsgLoggerRead;

    __android_log_add_transport(&__android_log_transport_read, &logdLoggerRead);
    __android_log_add_transport(&__android_log_persist_read, &pmsgLoggerRead);
        __android_log_add_transport(&__android_log_transport_read,
                                    &logdLoggerRead);
        __android_log_add_transport(&__android_log_persist_read,
                                    &pmsgLoggerRead);
    }
#endif
}

+21 −6
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@
 * limitations under the License.
 */

#include <log/log_frontend.h>

#include "config_write.h"
#include "logger.h"

@@ -52,18 +54,31 @@ static void __android_log_add_transport(
}

LIBLOG_HIDDEN void __android_log_config_write() {
    if (__android_log_frontend & LOGGER_LOCAL) {
        extern struct android_log_transport_write localLoggerWrite;

        __android_log_add_transport(&__android_log_transport_write,
                                    &localLoggerWrite);
    }

    if ((__android_log_frontend == LOGGER_DEFAULT) ||
        (__android_log_frontend & LOGGER_LOGD)) {
#if (FAKE_LOG_DEVICE == 0)
        extern struct android_log_transport_write logdLoggerWrite;
        extern struct android_log_transport_write pmsgLoggerWrite;

    __android_log_add_transport(&__android_log_transport_write, &logdLoggerWrite);
    __android_log_add_transport(&__android_log_persist_write, &pmsgLoggerWrite);
        __android_log_add_transport(&__android_log_transport_write,
                                    &logdLoggerWrite);
        __android_log_add_transport(&__android_log_persist_write,
                                    &pmsgLoggerWrite);
#else
        extern struct android_log_transport_write fakeLoggerWrite;

    __android_log_add_transport(&__android_log_transport_write, &fakeLoggerWrite);
        __android_log_add_transport(&__android_log_transport_write,
                                    &fakeLoggerWrite);
#endif
    }
}

LIBLOG_HIDDEN void __android_log_config_write_close() {
    struct android_log_transport_write *transport;
+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ extern "C" {
#define LOGGER_LOGD    0x1
#define LOGGER_KERNEL  0x2 /* Reserved/Deprecated */
#define LOGGER_NULL    0x4 /* Does not release resources of other selections */
#define LOGGER_LOCAL   0x8 /* logs sent to local memory */

/* Both return the selected frontend flag mask, or negative errno */
int android_set_log_frontend(int frontend_flag);
Loading