Commit graph

3 commits

Author SHA1 Message Date
Tom Cherry
69ee5dde99 Move default tag from libbase to liblog
Bug: 119867234
Test: log tags look right, libbase/liblog unit tests
Change-Id: I3670c3fdce3d0238a23a53bba2877ffed1291f9c
2020-01-23 08:39:31 -08:00
Tom Cherry
0391a879f7 Move minimum log priority from libbase to liblog
See the previous commit moving SetLogger and SetAborter to liblog for
motivation.

This creates more harmony between the two mechanisms in libbase and
liblog for checking loggability.
Currently:
1) libbase filters all messages based on its minimum log priority. For
   example, if minimum log priority in libbase remained at its
   default, but a tag was specifically opted into DEBUG logs via
   log.tag.<tag>, libbase would not print this log.
2) liblog ignores libbase's minimum log priority.  For example if a
   process called SetMinimumLogPriority(WARNING) but used a library
   that logged via liblog's ALOGI macro, that log would still be
   printed even though the process intends on filtering out those INFO
   messages.

With this change:
1) If both a minimum log priority and a priority through log.tag.<tag>
   are set, then the lower of the two values is used.
2) If only one or the other is set, then that value is used.  This
   fixes the two issues described above.
3) If neither of these values are set, then the default of using INFO
   is unchanged.

Bug: 116329414
Bug: 119867234
Test: libbase and liblog minimum log priority tests
Change-Id: Icb49b30b9d93bf797470e23730ae9e537931bb6c
2020-01-21 12:14:43 -08:00
Tom Cherry
349b0c43ad Move SetLogger and SetAborter from libbase to liblog
libbase is copied into each APEX module which requires it, meaning
that there may be multiple instances of libbase running within a
single process with their own copy of libbase's globals.  This means
that SetLogger() and SetAborter() will only impact logs from the
instance of libbase that calls it.  This change moves this state to
liblog, since it will only ever have one instance in a single
process.

One major side-effect here is that now both ALOGE style and LOG(...)
style logs will be handled through the same logger function.  For
example, a logger specified through libbase's SetLogger() will now see
logs sent to liblog through ALOGE().  This is intended behavior.

A second side-effect is that libbase's stderr logger is used for all
host logging now.  It's simply a better logging default than the
fake_log_device logger in liblog currently and makes ALOGE and
LOG(...) logs on host follow the same format.

Bug: 119867234
Test: libbase and liblog unit tests; logging works
Change-Id: Ib52cbfb4e43749e50910ed19a993dffae19ace86
2020-01-21 11:05:24 -08:00