1) Rename __android_logger_data to __android_log_message and rename
__android_log_write_logger_data to
__android_log_write_log_message. Move the const char* message
argument into __android_log_message.
2) Add @param, @return, and "Available since API level 30." to the
documentation of new functions.
3) Document that the user defined aborter should but may not abort.
4) Document the line separation is the responsibility of the log
function provided to __android_log_set_logger().
Bug: 150898477
Test: build, liblog and libbase unit tests
Change-Id: I07c41011ef25b3e7cc4943f3f1e240a2f6aa2802
In case multiple threads try to reference this variable while it is
being set, it should be atomic so that all threads always see a valid
value.
Bug: 150898477
Test: liblog, libbase unit tests
Change-Id: If6c9e291f2471b96a752dc6e76e3e63458b71391
These buffers are immediately written into with *printf() and are in
the hot path, so do not initialize them. This saves ~70ns off of each
log message, which is ~14% of the overhead within
__android_log_print() when writing to a no-op logger.
Test: liblog benchmarks
Change-Id: I2b898e72c75b57bc63fee565b49a4e00e377ed1a
Do not write to binary buffers, this was already done for logd,
but wasn't explicitly done for other loggers, so do that too.
Test: unit tests
Change-Id: Ia36e0d2e1b6c833780239a5ef459abea99bc4a1f
This is now dead code as __android_log_stderr_logger() has superseded it.
Bug: 147496863
Test: build
Change-Id: Ibdea2961ec4fc093bf9e35581dc1c46db2cff06a
Some recent changes can have these logging functions potentially set
errno. This change places android::base::ErrnoRestorer at the entry
point of the public functions where we want to guarantee errno is
restored to ensure this will not happen again.
Test: build
Change-Id: Iab4170ab16b9c7301474a509ee42d38b370b91a4
Only print logs with priority >= INFO on host, as fake_log_device
does.
This fixes a regression in host builds where loggability wasn't
checked at all.
Bug: 69935292
Test: ART host tests don't print extraneous logs
Change-Id: I885b794da6f24bd905192252925e4a9f88b06674
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
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
Cleanup the headers; we really don't want to encourage any more
cutils/list.h usage...
Remove __android_log_uid() since the only remaining users are built
for device, so they can just use getuid() directly.
Test: build
Change-Id: I62be2c1e43d83807deaa9342afcc72459947cf15
Remove the transport available and open functions since the writers
are able to manage their own state. Remove the initialization dance
with write_to_log, since it is unneeded once this is removed as well.
Remove the global lock around the close() functions as correct locking
has been added to the writers in a previous change.
Test: logging works, liblog-unit-tests
Change-Id: If7fa11e773763d0b5fcb2e696ad1c88ff4a4cfdf
This code was introduced to help performance by skipping sending these
messages to logd when logd would later drop them. However it has
multiple flaws:
1) Event logs aren't super common and non-loggable event logs are even
less common, so it would be a trivial benefit if any.
2) This code is not particularly safe as written, which is even
acknowledged in the comments.
3) This forces processes that write event logs to allocate a rather
sizable amount of memory.
Therefore, it's better to simply remove this and let logd drop these
messages when it receives them.
Bug: 139705697
Test: logging works, liblog-unit-tests
Change-Id: Ide01574112e173d4922137b3d3868cf8c2c09086
The old code did not free the transports, just unlink their nodes from
the linked list, so there was no race condition between close() and
other threads writing to the logs. By settings these to nullptr, I
introduced a race condition, but setting them to nullptr isn't
necessary, so let's simply not do that.
Test: liblog-unit-tests
Change-Id: Iec0b680addd13b5d30bd91ccef5bdeab6bf797b0
These checks are not needed; all callers are in this file and there's
only one possible situation: that we have valid pointers and sizes.
Test: liblog-unit-tests, log.tag.* properties still work
Change-Id: I8b385d5124c2d93cd99a352e30f745b075c8bd09
Now that we only have one transport in a given build configuration,
there is no need to have these lists.
Test: liblog-unit-tests
Change-Id: I3fdcdc33c1224a9522080ea06f36f14c83d946ac
There are no users; future versions will need to be more generic to
support the libbase style Logger/Aborter options.
Test: build, liblog-unit-tests
Change-Id: Ia4571cd39d3e499f18306920ecbf40ea8878fb81
There are no users of the liblog stderr logger, but 66 users of
android::base::StderrLogger. We'll prefer that format and work to
merge it into liblog.
Test: liblog-unit-tests
Change-Id: Ifad24b27ac0f51379b925f6644caa1f6f3d9ad81
liblog has left over code from local_logger that allows for reading
from multiple sources and merging the contents. Since we've already
removed local_logger, this change removes the rest of this code.
Test: liblog-unit-tests
Change-Id: I5685ad6c1e7cbcaa0a660ed10f47714784a40791
The code section is already marked as to be removed, simply suppress
the -Wstring-plus-int warning.
Test: m checkbuild
Bug: 128878287
Change-Id: I95a03aca90dbb5d27db49f5baf534cbaacf9b830
readv() isn't used by anyone, writev() has one easily replaced user.
uio.h can be left as a private header for windows compatibility with
struct iovec.
Test: build
Change-Id: I33d4c6bdee6fd818271f78ae06abdd2aa09430f2