Allow the default tag (the program name) to be overwritten.
Bug: 34867873
Test: m
Test: logging_test
Test: manual
Change-Id: I4ef32bad413a7cc82e46ce16a2f26212925964b1
Undo zero-termination-substitution for linebreaks when logging.
This results in handing the complete log message to the aborter.
Add a test.
Bug: 31893081
Test: mmma system/core/base && $ANDROID_HOST_OUT/nativetest64/libbase_test/libbase_test64
Change-Id: I2ef6c6351db2fd494a02985f634f439104136227
Partially reverts commit 436f5a031f.
Remove the variants taking a fully qualified LogSeverity. Instead
use a lambda with "using" statements to translate both qualified
and unqualified names into valid expressions.
Compile-time regression was measured as 0.1s for a thousand LOG
statements on a z840.
Update tests.
Bug: 31338270
Test: m
Test: mmma system/core/base && $ANDROID_HOST_OUT/nativetest64/libbase_test/libbase_test64
Change-Id: I36fdf30a9d535b19543307b85d1b3c19a97f20dd
Add WOULD_LOG to determine whether a given severity would be logged.
Add LOG_STREAM to have direct access to a logging stream.
Add LOG_S variants that take a fully qualified severity. This allows
complex expressions as parameters, e.g., ternaries for conditional
severity levels.
Add tests.
Bug: 31338270
Test: m
Test: mmma system/core/base && $ANDROID_HOST_OUT/nativetest64/libbase_test/libbase_test64
Change-Id: I242b960594e68caff6db9cd8aaa4ce8aaf90474c
Add the INTERNAL_FATAL level. It will print 'F' like FATAL, but
does not abort after logging.
Add a test to logging_test.
Bug: 31338270
Test: m
Test: mmma system/core/base && adb sync && adb shell /data/nativetest/libbase_test/libbase_test32
Change-Id: Idf74c08e8516881efccaefc58fa3f41d57e56396
Use ECMAscript regex syntax (the default!) for a simpler regex.
Also test the cartesian product of logging options, with less copy & paste
than the previous test of a subset.
Change-Id: I7aae91d276dbbb8de6173d18b5c1ceb01c1dff73
Fix LOG() to properly save and restore errno. Test this properly.
Only do logging if severity is >= the minimum.
Fix dangling if statements in CHECK(), CHECK_STR{EQ,NE}(). Test this
properly.
Fix base logging tests on Windows. All libbase_tests now pass on
Windows.
Change place to lock, so the lock can protect logging of all data in
LogMessage.
Change-Id: I7ff531c67ae10a99ef0a2bbfe279aa77282d5ae9
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
Win32:
- getprogname(): call basename() which is available in mingw's crt.
Don't potentially go recursive with DCHECK_GT().
- Use Win32 critical section instead of mutex.
Other:
- Change log_characters check to compile-time.
- Fix code that gets the basename of __FILE__. The previous code was not
setting _file, so it didn't work.
- Save and restore errno for LOG calls. Inspired by similar Chromium code.
Change-Id: Ie7bb700918be726fa81d60177d1894d2daeff296
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
~ Rewrote mkdirs to be in C++ style.
~ Replaced adb_dir{start,stop} with std::string params and (r)find.
+ Added test for mkdirs.
Also make base/test_utils.h public and support temporary directories
as well as files.
Change-Id: I6fcbdc5e0099f3359d3aac6b00c436f250ca1329
libc++ doesn't support std::mutex and friends for Windows yet, so we
just use a compatibility wrapper for now.
Change-Id: I2413d4c089e7d0fb232444043c6b772153035dab
While the defaults (logd or stderr) make sense for most use cases,
there are places that can only log to the kernel, or need to log to a
file, etc.
Allow the user to pass in an arbitrary logging object, and provide
LogdLogger and StderrLogger as defaults.
Change-Id: I62368acc795ff313242bb205d65017404bf64e88
ART already had a flavor of this, but it was specialized for their use
case a bit.
Note that the logging.* tests are currently disabled for the device
because there is no good way to capture the output of liblog. We can
make something that will execute logcat and then then scan the output,
but that's messy. Since we know it at least works on the host, we can
add better device tests later.
Change-Id: I47acd87a3312c0a5285b03f9c8dadef0c669f06a