libbase: TeeLogger
Combine multiple log streams.
Convenient for tests and utilities that want to dump things to stdout
for devs and logcat so logs are interleaved there.
Bug: N/A
Test: use with misctrl
Change-Id: I8037e71cab495905944aa399f0691e4349e4c0f7
diff --git a/logging.cpp b/logging.cpp
index b296d3b..facebc3 100644
--- a/logging.cpp
+++ b/logging.cpp
@@ -295,6 +295,15 @@
}
}
+LogFunction TeeLogger(LogFunction&& l1, LogFunction&& l2) {
+ return [l1 = std::move(l1), l2 = std::move(l2)](LogId id, LogSeverity severity, const char* tag,
+ const char* file, unsigned int line,
+ const char* message) {
+ l1(id, severity, tag, file, line, message);
+ l2(id, severity, tag, file, line, message);
+ };
+}
+
void DefaultAborter(const char* abort_message) {
#ifdef __ANDROID__
android_set_abort_message(abort_message);