| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| Elliott Hughes | 8cf75f0 | 2016-08-04 16:09:39 -0700 | [diff] [blame] | 17 | #if defined(_WIN32) |
| Spencer Low | 4759052 | 2015-05-19 22:12:06 -0700 | [diff] [blame] | 18 | #include <windows.h> |
| 19 | #endif |
| 20 | |
| Elliott Hughes | b635162 | 2015-12-04 22:00:26 -0800 | [diff] [blame] | 21 | #include "android-base/logging.h" |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 22 | |
| Elliott Hughes | 8cf75f0 | 2016-08-04 16:09:39 -0700 | [diff] [blame] | 23 | #include <fcntl.h> |
| Josh Gao | ef102be | 2018-03-16 14:25:42 -0700 | [diff] [blame] | 24 | #include <inttypes.h> |
| Dan Albert | 1be4dec | 2015-04-03 11:28:46 -0700 | [diff] [blame] | 25 | #include <libgen.h> |
| Elliott Hughes | 6522eb5 | 2016-06-21 14:25:44 -0700 | [diff] [blame] | 26 | #include <time.h> |
| Dan Albert | 1be4dec | 2015-04-03 11:28:46 -0700 | [diff] [blame] | 27 | |
| 28 | // For getprogname(3) or program_invocation_short_name. |
| 29 | #if defined(__ANDROID__) || defined(__APPLE__) |
| 30 | #include <stdlib.h> |
| 31 | #elif defined(__GLIBC__) |
| 32 | #include <errno.h> |
| 33 | #endif |
| 34 | |
| Tom Cherry | 1bfa8ab | 2020-01-08 14:47:42 -0800 | [diff] [blame] | 35 | #include <atomic> |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 36 | #include <iostream> |
| 37 | #include <limits> |
| Josh Gao | b08de45 | 2016-09-13 14:57:12 -0700 | [diff] [blame] | 38 | #include <mutex> |
| Tom Cherry | 1bfa8ab | 2020-01-08 14:47:42 -0800 | [diff] [blame] | 39 | #include <optional> |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 40 | #include <sstream> |
| 41 | #include <string> |
| Dan Albert | 1f65c49 | 2015-03-27 11:20:14 -0700 | [diff] [blame] | 42 | #include <utility> |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 43 | #include <vector> |
| 44 | |
| Andreas Gampe | ed91707 | 2018-02-15 11:40:30 -0800 | [diff] [blame] | 45 | #include <android/log.h> |
| Tom Cherry | 17e8580 | 2020-01-08 13:41:56 -0800 | [diff] [blame] | 46 | #ifdef __ANDROID__ |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 47 | #include <android/set_abort_message.h> |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 48 | #else |
| 49 | #include <sys/types.h> |
| 50 | #include <unistd.h> |
| 51 | #endif |
| 52 | |
| Elliott Hughes | 397961e | 2018-10-19 13:59:44 -0700 | [diff] [blame] | 53 | #include <android-base/file.h> |
| Mark Salyzyn | 5cbb251 | 2016-09-28 15:54:45 -0700 | [diff] [blame] | 54 | #include <android-base/macros.h> |
| Mark Salyzyn | 504d8ed | 2018-04-06 09:40:26 -0700 | [diff] [blame] | 55 | #include <android-base/parseint.h> |
| Mark Salyzyn | 5cbb251 | 2016-09-28 15:54:45 -0700 | [diff] [blame] | 56 | #include <android-base/strings.h> |
| Josh Gao | ef102be | 2018-03-16 14:25:42 -0700 | [diff] [blame] | 57 | #include <android-base/threads.h> |
| Elliott Hughes | 774d7f6 | 2015-11-11 18:02:29 +0000 | [diff] [blame] | 58 | |
| Tom Cherry | a687242 | 2020-04-17 13:05:11 -0700 | [diff] [blame] | 59 | #include "logging_splitters.h" |
| Tom Cherry | 1bfa8ab | 2020-01-08 14:47:42 -0800 | [diff] [blame] | 60 | |
| Elliott Hughes | 462a45e | 2018-06-06 12:54:41 -0700 | [diff] [blame] | 61 | namespace android { |
| 62 | namespace base { |
| 63 | |
| 64 | // BSD-based systems like Android/macOS have getprogname(). Others need us to provide one. |
| Colin Cross | 18c2bd4 | 2021-07-14 15:07:58 -0700 | [diff] [blame] | 65 | #if !defined(__APPLE__) && !defined(__BIONIC__) |
| Elliott Hughes | 462a45e | 2018-06-06 12:54:41 -0700 | [diff] [blame] | 66 | static const char* getprogname() { |
| Colin Cross | 18c2bd4 | 2021-07-14 15:07:58 -0700 | [diff] [blame] | 67 | #ifdef _WIN32 |
| Dan Albert | dc15ffd | 2015-04-29 11:32:23 -0700 | [diff] [blame] | 68 | static bool first = true; |
| 69 | static char progname[MAX_PATH] = {}; |
| 70 | |
| 71 | if (first) { |
| Elliott Hughes | 397961e | 2018-10-19 13:59:44 -0700 | [diff] [blame] | 72 | snprintf(progname, sizeof(progname), "%s", |
| 73 | android::base::Basename(android::base::GetExecutablePath()).c_str()); |
| Dan Albert | dc15ffd | 2015-04-29 11:32:23 -0700 | [diff] [blame] | 74 | first = false; |
| 75 | } |
| 76 | |
| 77 | return progname; |
| Colin Cross | 18c2bd4 | 2021-07-14 15:07:58 -0700 | [diff] [blame] | 78 | #else |
| 79 | return program_invocation_short_name; |
| Elliott Hughes | 462a45e | 2018-06-06 12:54:41 -0700 | [diff] [blame] | 80 | #endif |
| Dan Albert | dc15ffd | 2015-04-29 11:32:23 -0700 | [diff] [blame] | 81 | } |
| Dan Albert | dc15ffd | 2015-04-29 11:32:23 -0700 | [diff] [blame] | 82 | #endif |
| Mark Salyzyn | 504d8ed | 2018-04-06 09:40:26 -0700 | [diff] [blame] | 83 | |
| Elliott Hughes | 462a45e | 2018-06-06 12:54:41 -0700 | [diff] [blame] | 84 | static const char* GetFileBasename(const char* file) { |
| 85 | // We can't use basename(3) even on Unix because the Mac doesn't |
| 86 | // have a non-modifying basename. |
| 87 | const char* last_slash = strrchr(file, '/'); |
| 88 | if (last_slash != nullptr) { |
| 89 | return last_slash + 1; |
| 90 | } |
| 91 | #if defined(_WIN32) |
| 92 | const char* last_backslash = strrchr(file, '\\'); |
| 93 | if (last_backslash != nullptr) { |
| 94 | return last_backslash + 1; |
| 95 | } |
| 96 | #endif |
| 97 | return file; |
| 98 | } |
| 99 | |
| Mark Salyzyn | 504d8ed | 2018-04-06 09:40:26 -0700 | [diff] [blame] | 100 | #if defined(__linux__) |
| Elliott Hughes | 462a45e | 2018-06-06 12:54:41 -0700 | [diff] [blame] | 101 | static int OpenKmsg() { |
| Mark Salyzyn | 504d8ed | 2018-04-06 09:40:26 -0700 | [diff] [blame] | 102 | #if defined(__ANDROID__) |
| Elliott Hughes | 3891348 | 2024-05-30 19:49:57 +0000 | [diff] [blame] | 103 | // Pick up `file /dev/kmsg w` environment from a daemon's init .rc file. |
| 104 | // If you're wondering why you're not seeing kernel logs from your daemon, |
| 105 | // it's probably because you're missing that line in your .rc file! |
| 106 | // You'll also need to `allow <your_domain> kmsg_device:chr_file w_file_perms;` |
| 107 | // in `system/sepolocy/private/<your_domain>.te`. |
| Mark Salyzyn | 504d8ed | 2018-04-06 09:40:26 -0700 | [diff] [blame] | 108 | const auto val = getenv("ANDROID_FILE__dev_kmsg"); |
| 109 | if (val != nullptr) { |
| 110 | int fd; |
| 111 | if (android::base::ParseInt(val, &fd, 0)) { |
| 112 | auto flags = fcntl(fd, F_GETFL); |
| 113 | if ((flags != -1) && ((flags & O_ACCMODE) == O_WRONLY)) return fd; |
| 114 | } |
| 115 | } |
| 116 | #endif |
| Elliott Hughes | 3891348 | 2024-05-30 19:49:57 +0000 | [diff] [blame] | 117 | // Note that this is _not_ the normal case: this is primarily for init itself. |
| 118 | // Most other code will need to inherit an fd from init, as described above. |
| Mark Salyzyn | 504d8ed | 2018-04-06 09:40:26 -0700 | [diff] [blame] | 119 | return TEMP_FAILURE_RETRY(open("/dev/kmsg", O_WRONLY | O_CLOEXEC)); |
| 120 | } |
| 121 | #endif |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 122 | |
| Tom Cherry | 784ba9a | 2020-03-12 11:07:07 -0700 | [diff] [blame] | 123 | static LogId log_id_tToLogId(int32_t buffer_id) { |
| Tom Cherry | 1bfa8ab | 2020-01-08 14:47:42 -0800 | [diff] [blame] | 124 | switch (buffer_id) { |
| 125 | case LOG_ID_MAIN: |
| 126 | return MAIN; |
| 127 | case LOG_ID_SYSTEM: |
| 128 | return SYSTEM; |
| 129 | case LOG_ID_RADIO: |
| 130 | return RADIO; |
| 131 | case LOG_ID_CRASH: |
| 132 | return CRASH; |
| 133 | case LOG_ID_DEFAULT: |
| 134 | default: |
| 135 | return DEFAULT; |
| 136 | } |
| 137 | } |
| 138 | |
| Tom Cherry | 784ba9a | 2020-03-12 11:07:07 -0700 | [diff] [blame] | 139 | static int32_t LogIdTolog_id_t(LogId log_id) { |
| Tom Cherry | 1bfa8ab | 2020-01-08 14:47:42 -0800 | [diff] [blame] | 140 | switch (log_id) { |
| 141 | case MAIN: |
| 142 | return LOG_ID_MAIN; |
| 143 | case SYSTEM: |
| 144 | return LOG_ID_SYSTEM; |
| 145 | case RADIO: |
| 146 | return LOG_ID_RADIO; |
| 147 | case CRASH: |
| 148 | return LOG_ID_CRASH; |
| 149 | case DEFAULT: |
| 150 | default: |
| 151 | return LOG_ID_DEFAULT; |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | static LogSeverity PriorityToLogSeverity(int priority) { |
| 156 | switch (priority) { |
| Tom Cherry | 4916e09 | 2020-01-16 15:58:02 -0800 | [diff] [blame] | 157 | case ANDROID_LOG_DEFAULT: |
| 158 | return INFO; |
| Tom Cherry | 1bfa8ab | 2020-01-08 14:47:42 -0800 | [diff] [blame] | 159 | case ANDROID_LOG_VERBOSE: |
| 160 | return VERBOSE; |
| 161 | case ANDROID_LOG_DEBUG: |
| 162 | return DEBUG; |
| 163 | case ANDROID_LOG_INFO: |
| 164 | return INFO; |
| 165 | case ANDROID_LOG_WARN: |
| 166 | return WARNING; |
| 167 | case ANDROID_LOG_ERROR: |
| 168 | return ERROR; |
| 169 | case ANDROID_LOG_FATAL: |
| 170 | return FATAL; |
| 171 | default: |
| 172 | return FATAL; |
| 173 | } |
| 174 | } |
| 175 | |
| Tom Cherry | 784ba9a | 2020-03-12 11:07:07 -0700 | [diff] [blame] | 176 | static int32_t LogSeverityToPriority(LogSeverity severity) { |
| Tom Cherry | 1bfa8ab | 2020-01-08 14:47:42 -0800 | [diff] [blame] | 177 | switch (severity) { |
| 178 | case VERBOSE: |
| 179 | return ANDROID_LOG_VERBOSE; |
| 180 | case DEBUG: |
| 181 | return ANDROID_LOG_DEBUG; |
| 182 | case INFO: |
| 183 | return ANDROID_LOG_INFO; |
| 184 | case WARNING: |
| 185 | return ANDROID_LOG_WARN; |
| 186 | case ERROR: |
| 187 | return ANDROID_LOG_ERROR; |
| 188 | case FATAL_WITHOUT_ABORT: |
| 189 | case FATAL: |
| 190 | default: |
| 191 | return ANDROID_LOG_FATAL; |
| 192 | } |
| 193 | } |
| 194 | |
| Yabin Cui | 7ff958a | 2017-01-23 10:29:23 -0800 | [diff] [blame] | 195 | static LogFunction& Logger() { |
| Dan Albert | 1f65c49 | 2015-03-27 11:20:14 -0700 | [diff] [blame] | 196 | #ifdef __ANDROID__ |
| Yabin Cui | 7ff958a | 2017-01-23 10:29:23 -0800 | [diff] [blame] | 197 | static auto& logger = *new LogFunction(LogdLogger()); |
| Dan Albert | 1f65c49 | 2015-03-27 11:20:14 -0700 | [diff] [blame] | 198 | #else |
| Yabin Cui | 7ff958a | 2017-01-23 10:29:23 -0800 | [diff] [blame] | 199 | static auto& logger = *new LogFunction(StderrLogger); |
| Dan Albert | 1f65c49 | 2015-03-27 11:20:14 -0700 | [diff] [blame] | 200 | #endif |
| Yabin Cui | 7ff958a | 2017-01-23 10:29:23 -0800 | [diff] [blame] | 201 | return logger; |
| 202 | } |
| Dan Albert | 1f65c49 | 2015-03-27 11:20:14 -0700 | [diff] [blame] | 203 | |
| Yabin Cui | 7ff958a | 2017-01-23 10:29:23 -0800 | [diff] [blame] | 204 | static AbortFunction& Aborter() { |
| 205 | static auto& aborter = *new AbortFunction(DefaultAborter); |
| 206 | return aborter; |
| 207 | } |
| 208 | |
| Tom Cherry | dbc07ce | 2020-01-22 07:48:42 -0800 | [diff] [blame] | 209 | // Only used for Q fallback. |
| Andreas Gampe | fec5b09 | 2018-03-05 10:00:19 -0800 | [diff] [blame] | 210 | static std::recursive_mutex& TagLock() { |
| 211 | static auto& tag_lock = *new std::recursive_mutex(); |
| 212 | return tag_lock; |
| 213 | } |
| Tom Cherry | dbc07ce | 2020-01-22 07:48:42 -0800 | [diff] [blame] | 214 | // Only used for Q fallback. |
| Andreas Gampe | fec5b09 | 2018-03-05 10:00:19 -0800 | [diff] [blame] | 215 | static std::string* gDefaultTag; |
| Tom Cherry | dbc07ce | 2020-01-22 07:48:42 -0800 | [diff] [blame] | 216 | |
| Andreas Gampe | fec5b09 | 2018-03-05 10:00:19 -0800 | [diff] [blame] | 217 | void SetDefaultTag(const std::string& tag) { |
| Jiyong Park | ecb6afe | 2020-08-10 21:27:51 +0900 | [diff] [blame] | 218 | if (__builtin_available(android 30, *)) { |
| 219 | __android_log_set_default_tag(tag.c_str()); |
| Tom Cherry | dbc07ce | 2020-01-22 07:48:42 -0800 | [diff] [blame] | 220 | } else { |
| 221 | std::lock_guard<std::recursive_mutex> lock(TagLock()); |
| 222 | if (gDefaultTag != nullptr) { |
| 223 | delete gDefaultTag; |
| 224 | gDefaultTag = nullptr; |
| 225 | } |
| 226 | if (!tag.empty()) { |
| 227 | gDefaultTag = new std::string(tag); |
| 228 | } |
| Andreas Gampe | fec5b09 | 2018-03-05 10:00:19 -0800 | [diff] [blame] | 229 | } |
| Yabin Cui | 7ff958a | 2017-01-23 10:29:23 -0800 | [diff] [blame] | 230 | } |
| Andreas Gampe | 9008e8d | 2016-09-08 11:03:58 -0700 | [diff] [blame] | 231 | |
| Dan Albert | 1be4dec | 2015-04-03 11:28:46 -0700 | [diff] [blame] | 232 | static bool gInitialized = false; |
| Tom Cherry | 4916e09 | 2020-01-16 15:58:02 -0800 | [diff] [blame] | 233 | |
| 234 | // Only used for Q fallback. |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 235 | static LogSeverity gMinimumLogSeverity = INFO; |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 236 | |
| Elliott Hughes | 8cf75f0 | 2016-08-04 16:09:39 -0700 | [diff] [blame] | 237 | #if defined(__linux__) |
| Tom Cherry | a687242 | 2020-04-17 13:05:11 -0700 | [diff] [blame] | 238 | static void KernelLogLine(const char* msg, int length, android::base::LogSeverity severity, |
| 239 | const char* tag) { |
| Andreas Gampe | d2a4f21 | 2016-09-07 10:10:50 -0700 | [diff] [blame] | 240 | // clang-format off |
| Elliott Hughes | 8cf75f0 | 2016-08-04 16:09:39 -0700 | [diff] [blame] | 241 | static constexpr int kLogSeverityToKernelLogLevel[] = { |
| Andreas Gampe | d2a4f21 | 2016-09-07 10:10:50 -0700 | [diff] [blame] | 242 | [android::base::VERBOSE] = 7, // KERN_DEBUG (there is no verbose kernel log |
| 243 | // level) |
| 244 | [android::base::DEBUG] = 7, // KERN_DEBUG |
| 245 | [android::base::INFO] = 6, // KERN_INFO |
| 246 | [android::base::WARNING] = 4, // KERN_WARNING |
| 247 | [android::base::ERROR] = 3, // KERN_ERROR |
| 248 | [android::base::FATAL_WITHOUT_ABORT] = 2, // KERN_CRIT |
| 249 | [android::base::FATAL] = 2, // KERN_CRIT |
| Elliott Hughes | 8cf75f0 | 2016-08-04 16:09:39 -0700 | [diff] [blame] | 250 | }; |
| Andreas Gampe | d2a4f21 | 2016-09-07 10:10:50 -0700 | [diff] [blame] | 251 | // clang-format on |
| Elliott Hughes | 8cf75f0 | 2016-08-04 16:09:39 -0700 | [diff] [blame] | 252 | static_assert(arraysize(kLogSeverityToKernelLogLevel) == android::base::FATAL + 1, |
| 253 | "Mismatch in size of kLogSeverityToKernelLogLevel and values in LogSeverity"); |
| 254 | |
| Mark Salyzyn | 504d8ed | 2018-04-06 09:40:26 -0700 | [diff] [blame] | 255 | static int klog_fd = OpenKmsg(); |
| Elliott Hughes | 8cf75f0 | 2016-08-04 16:09:39 -0700 | [diff] [blame] | 256 | if (klog_fd == -1) return; |
| 257 | |
| 258 | int level = kLogSeverityToKernelLogLevel[severity]; |
| 259 | |
| Yi-Yo Chiang | 02cdbf2 | 2021-03-17 16:34:35 +0800 | [diff] [blame] | 260 | // The kernel's printk buffer is only |1024 - PREFIX_MAX| bytes, where |
| 261 | // PREFIX_MAX could be 48 or 32. |
| 262 | // Reference: kernel/printk/printk.c |
| Yi-Yo Chiang | 02cdbf2 | 2021-03-17 16:34:35 +0800 | [diff] [blame] | 263 | static constexpr int LOG_LINE_MAX = 1024 - 48; |
| 264 | char buf[LOG_LINE_MAX] __attribute__((__uninitialized__)); |
| Tom Cherry | a687242 | 2020-04-17 13:05:11 -0700 | [diff] [blame] | 265 | size_t size = snprintf(buf, sizeof(buf), "<%d>%s: %.*s\n", level, tag, length, msg); |
| Yi-Yo Chiang | 1b96cbd | 2021-03-18 01:23:58 +0800 | [diff] [blame] | 266 | TEMP_FAILURE_RETRY(write(klog_fd, buf, std::min(size, sizeof(buf)))); |
| Elliott Hughes | 8cf75f0 | 2016-08-04 16:09:39 -0700 | [diff] [blame] | 267 | |
| Yi-Yo Chiang | 1b96cbd | 2021-03-18 01:23:58 +0800 | [diff] [blame] | 268 | if (size > sizeof(buf)) { |
| 269 | size_t truncated = size - sizeof(buf); |
| 270 | size = snprintf( |
| 271 | buf, sizeof(buf), |
| 272 | "<%d>%s: **previous message missing %zu bytes** %zu-byte message too long for printk\n", |
| 273 | level, tag, truncated, size); |
| 274 | TEMP_FAILURE_RETRY(write(klog_fd, buf, std::min(size, sizeof(buf)))); |
| 275 | } |
| Elliott Hughes | 8cf75f0 | 2016-08-04 16:09:39 -0700 | [diff] [blame] | 276 | } |
| Tom Cherry | a687242 | 2020-04-17 13:05:11 -0700 | [diff] [blame] | 277 | |
| 278 | void KernelLogger(android::base::LogId, android::base::LogSeverity severity, const char* tag, |
| 279 | const char*, unsigned int, const char* full_message) { |
| 280 | SplitByLines(full_message, KernelLogLine, severity, tag); |
| 281 | } |
| Elliott Hughes | 8cf75f0 | 2016-08-04 16:09:39 -0700 | [diff] [blame] | 282 | #endif |
| 283 | |
| Tomasz Wasilczyk | a419de2 | 2017-12-18 06:30:17 -0800 | [diff] [blame] | 284 | void StderrLogger(LogId, LogSeverity severity, const char* tag, const char* file, unsigned int line, |
| 285 | const char* message) { |
| Jiyong Park | 5ac7e59 | 2023-06-27 16:55:19 +0900 | [diff] [blame] | 286 | struct timespec ts; |
| 287 | clock_gettime(CLOCK_REALTIME, &ts); |
| Tom Cherry | a687242 | 2020-04-17 13:05:11 -0700 | [diff] [blame] | 288 | auto output_string = |
| Jiyong Park | 5ac7e59 | 2023-06-27 16:55:19 +0900 | [diff] [blame] | 289 | StderrOutputGenerator(ts, getpid(), GetThreadId(), severity, tag, file, line, message); |
| Elliott Hughes | 6522eb5 | 2016-06-21 14:25:44 -0700 | [diff] [blame] | 290 | |
| Tom Cherry | a687242 | 2020-04-17 13:05:11 -0700 | [diff] [blame] | 291 | fputs(output_string.c_str(), stderr); |
| Dan Albert | 1f65c49 | 2015-03-27 11:20:14 -0700 | [diff] [blame] | 292 | } |
| 293 | |
| Elliott Hughes | 1c1409f | 2018-05-23 09:16:46 -0700 | [diff] [blame] | 294 | void StdioLogger(LogId, LogSeverity severity, const char* /*tag*/, const char* /*file*/, |
| 295 | unsigned int /*line*/, const char* message) { |
| 296 | if (severity >= WARNING) { |
| 297 | fflush(stdout); |
| Elliott Hughes | 462a45e | 2018-06-06 12:54:41 -0700 | [diff] [blame] | 298 | fprintf(stderr, "%s: %s\n", GetFileBasename(getprogname()), message); |
| Elliott Hughes | 1c1409f | 2018-05-23 09:16:46 -0700 | [diff] [blame] | 299 | } else { |
| 300 | fprintf(stdout, "%s\n", message); |
| 301 | } |
| 302 | } |
| 303 | |
| Steven Moreland | e4116cf | 2024-02-20 18:38:48 +0000 | [diff] [blame] | 304 | LogFunction TeeLogger(LogFunction&& l1, LogFunction&& l2) { |
| 305 | return [l1 = std::move(l1), l2 = std::move(l2)](LogId id, LogSeverity severity, const char* tag, |
| 306 | const char* file, unsigned int line, |
| 307 | const char* message) { |
| 308 | l1(id, severity, tag, file, line, message); |
| 309 | l2(id, severity, tag, file, line, message); |
| 310 | }; |
| 311 | } |
| 312 | |
| Andreas Gampe | 9008e8d | 2016-09-08 11:03:58 -0700 | [diff] [blame] | 313 | void DefaultAborter(const char* abort_message) { |
| 314 | #ifdef __ANDROID__ |
| 315 | android_set_abort_message(abort_message); |
| 316 | #else |
| 317 | UNUSED(abort_message); |
| 318 | #endif |
| 319 | abort(); |
| 320 | } |
| 321 | |
| Tom Cherry | a687242 | 2020-04-17 13:05:11 -0700 | [diff] [blame] | 322 | static void LogdLogChunk(LogId id, LogSeverity severity, const char* tag, const char* message) { |
| Tom Cherry | 784ba9a | 2020-03-12 11:07:07 -0700 | [diff] [blame] | 323 | int32_t lg_id = LogIdTolog_id_t(id); |
| Tom Cherry | a687242 | 2020-04-17 13:05:11 -0700 | [diff] [blame] | 324 | int32_t priority = LogSeverityToPriority(severity); |
| Tom Cherry | 1bfa8ab | 2020-01-08 14:47:42 -0800 | [diff] [blame] | 325 | |
| Jiyong Park | ecb6afe | 2020-08-10 21:27:51 +0900 | [diff] [blame] | 326 | if (__builtin_available(android 30, *)) { |
| Tom Cherry | 228eff1 | 2020-03-11 11:07:13 -0700 | [diff] [blame] | 327 | __android_log_message log_message = {sizeof(__android_log_message), lg_id, priority, tag, |
| 328 | static_cast<const char*>(nullptr), 0, message}; |
| Jiyong Park | ecb6afe | 2020-08-10 21:27:51 +0900 | [diff] [blame] | 329 | __android_log_logd_logger(&log_message); |
| Dan Albert | 1f65c49 | 2015-03-27 11:20:14 -0700 | [diff] [blame] | 330 | } else { |
| 331 | __android_log_buf_print(lg_id, priority, tag, "%s", message); |
| 332 | } |
| 333 | } |
| Dan Albert | 1f65c49 | 2015-03-27 11:20:14 -0700 | [diff] [blame] | 334 | |
| Tom Cherry | a687242 | 2020-04-17 13:05:11 -0700 | [diff] [blame] | 335 | LogdLogger::LogdLogger(LogId default_log_id) : default_log_id_(default_log_id) {} |
| 336 | |
| 337 | void LogdLogger::operator()(LogId id, LogSeverity severity, const char* tag, const char* file, |
| 338 | unsigned int line, const char* message) { |
| 339 | if (id == DEFAULT) { |
| 340 | id = default_log_id_; |
| 341 | } |
| 342 | |
| 343 | SplitByLogdChunks(id, severity, tag, file, line, message, LogdLogChunk); |
| 344 | } |
| 345 | |
| Andreas Gampe | 9008e8d | 2016-09-08 11:03:58 -0700 | [diff] [blame] | 346 | void InitLogging(char* argv[], LogFunction&& logger, AbortFunction&& aborter) { |
| Dan Albert | 1f65c49 | 2015-03-27 11:20:14 -0700 | [diff] [blame] | 347 | SetLogger(std::forward<LogFunction>(logger)); |
| Andreas Gampe | 9008e8d | 2016-09-08 11:03:58 -0700 | [diff] [blame] | 348 | SetAborter(std::forward<AbortFunction>(aborter)); |
| Dan Albert | 1f65c49 | 2015-03-27 11:20:14 -0700 | [diff] [blame] | 349 | |
| Dan Albert | 1be4dec | 2015-04-03 11:28:46 -0700 | [diff] [blame] | 350 | if (gInitialized) { |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 351 | return; |
| 352 | } |
| 353 | |
| Dan Albert | 1be4dec | 2015-04-03 11:28:46 -0700 | [diff] [blame] | 354 | gInitialized = true; |
| 355 | |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 356 | // Stash the command line for later use. We can use /proc/self/cmdline on |
| Spencer Low | bec7862 | 2015-11-07 18:51:54 -0800 | [diff] [blame] | 357 | // Linux to recover this, but we don't have that luxury on the Mac/Windows, |
| 358 | // and there are a couple of argv[0] variants that are commonly used. |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 359 | if (argv != nullptr) { |
| Andreas Gampe | fec5b09 | 2018-03-05 10:00:19 -0800 | [diff] [blame] | 360 | SetDefaultTag(basename(argv[0])); |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 361 | } |
| Dan Albert | 1be4dec | 2015-04-03 11:28:46 -0700 | [diff] [blame] | 362 | |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 363 | const char* tags = getenv("ANDROID_LOG_TAGS"); |
| 364 | if (tags == nullptr) { |
| 365 | return; |
| 366 | } |
| 367 | |
| Dan Albert | 0d716d0 | 2015-03-19 13:24:26 -0700 | [diff] [blame] | 368 | std::vector<std::string> specs = Split(tags, " "); |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 369 | for (size_t i = 0; i < specs.size(); ++i) { |
| 370 | // "tag-pattern:[vdiwefs]" |
| 371 | std::string spec(specs[i]); |
| 372 | if (spec.size() == 3 && StartsWith(spec, "*:")) { |
| 373 | switch (spec[2]) { |
| 374 | case 'v': |
| Tom Cherry | 4916e09 | 2020-01-16 15:58:02 -0800 | [diff] [blame] | 375 | SetMinimumLogSeverity(VERBOSE); |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 376 | continue; |
| 377 | case 'd': |
| Tom Cherry | 4916e09 | 2020-01-16 15:58:02 -0800 | [diff] [blame] | 378 | SetMinimumLogSeverity(DEBUG); |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 379 | continue; |
| 380 | case 'i': |
| Tom Cherry | 4916e09 | 2020-01-16 15:58:02 -0800 | [diff] [blame] | 381 | SetMinimumLogSeverity(INFO); |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 382 | continue; |
| 383 | case 'w': |
| Tom Cherry | 4916e09 | 2020-01-16 15:58:02 -0800 | [diff] [blame] | 384 | SetMinimumLogSeverity(WARNING); |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 385 | continue; |
| 386 | case 'e': |
| Tom Cherry | 4916e09 | 2020-01-16 15:58:02 -0800 | [diff] [blame] | 387 | SetMinimumLogSeverity(ERROR); |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 388 | continue; |
| 389 | case 'f': |
| Tom Cherry | 4916e09 | 2020-01-16 15:58:02 -0800 | [diff] [blame] | 390 | SetMinimumLogSeverity(FATAL_WITHOUT_ABORT); |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 391 | continue; |
| Luke Huang | 317728b | 2020-07-30 03:04:39 +0800 | [diff] [blame] | 392 | // liblog will even suppress FATAL if you say 's' for silent, but fatal should |
| 393 | // never be suppressed. |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 394 | case 's': |
| Tom Cherry | 4916e09 | 2020-01-16 15:58:02 -0800 | [diff] [blame] | 395 | SetMinimumLogSeverity(FATAL_WITHOUT_ABORT); |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 396 | continue; |
| 397 | } |
| 398 | } |
| 399 | LOG(FATAL) << "unsupported '" << spec << "' in ANDROID_LOG_TAGS (" << tags |
| 400 | << ")"; |
| 401 | } |
| 402 | } |
| 403 | |
| Krzysztof Kosiński | ccbd5db | 2020-08-04 17:41:44 -0700 | [diff] [blame] | 404 | LogFunction SetLogger(LogFunction&& logger) { |
| 405 | LogFunction old_logger = std::move(Logger()); |
| Tom Cherry | 8a06da8 | 2020-04-22 11:37:26 -0700 | [diff] [blame] | 406 | Logger() = std::move(logger); |
| 407 | |
| Jiyong Park | ecb6afe | 2020-08-10 21:27:51 +0900 | [diff] [blame] | 408 | if (__builtin_available(android 30, *)) { |
| 409 | __android_log_set_logger([](const struct __android_log_message* log_message) { |
| Tom Cherry | 228eff1 | 2020-03-11 11:07:13 -0700 | [diff] [blame] | 410 | auto log_id = log_id_tToLogId(log_message->buffer_id); |
| 411 | auto severity = PriorityToLogSeverity(log_message->priority); |
| Tom Cherry | 1bfa8ab | 2020-01-08 14:47:42 -0800 | [diff] [blame] | 412 | |
| Tom Cherry | 8a06da8 | 2020-04-22 11:37:26 -0700 | [diff] [blame] | 413 | Logger()(log_id, severity, log_message->tag, log_message->file, log_message->line, |
| Tom Cherry | 228eff1 | 2020-03-11 11:07:13 -0700 | [diff] [blame] | 414 | log_message->message); |
| Tom Cherry | 1bfa8ab | 2020-01-08 14:47:42 -0800 | [diff] [blame] | 415 | }); |
| Tom Cherry | 1bfa8ab | 2020-01-08 14:47:42 -0800 | [diff] [blame] | 416 | } |
| Krzysztof Kosiński | ccbd5db | 2020-08-04 17:41:44 -0700 | [diff] [blame] | 417 | return old_logger; |
| Dan Albert | 1f65c49 | 2015-03-27 11:20:14 -0700 | [diff] [blame] | 418 | } |
| 419 | |
| Krzysztof Kosiński | ccbd5db | 2020-08-04 17:41:44 -0700 | [diff] [blame] | 420 | AbortFunction SetAborter(AbortFunction&& aborter) { |
| 421 | AbortFunction old_aborter = std::move(Aborter()); |
| Tom Cherry | 8a06da8 | 2020-04-22 11:37:26 -0700 | [diff] [blame] | 422 | Aborter() = std::move(aborter); |
| 423 | |
| Jiyong Park | ecb6afe | 2020-08-10 21:27:51 +0900 | [diff] [blame] | 424 | if (__builtin_available(android 30, *)) { |
| 425 | __android_log_set_aborter([](const char* abort_message) { Aborter()(abort_message); }); |
| Tom Cherry | 1bfa8ab | 2020-01-08 14:47:42 -0800 | [diff] [blame] | 426 | } |
| Krzysztof Kosiński | ccbd5db | 2020-08-04 17:41:44 -0700 | [diff] [blame] | 427 | return old_aborter; |
| Andreas Gampe | 9008e8d | 2016-09-08 11:03:58 -0700 | [diff] [blame] | 428 | } |
| 429 | |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 430 | // This indirection greatly reduces the stack impact of having lots of |
| 431 | // checks/logging in a function. |
| 432 | class LogMessageData { |
| 433 | public: |
| Tom Cherry | 46a2e0e | 2020-01-10 17:18:55 -0800 | [diff] [blame] | 434 | LogMessageData(const char* file, unsigned int line, LogSeverity severity, const char* tag, |
| 435 | int error) |
| Spencer Low | 55853a9 | 2015-08-11 16:00:13 -0700 | [diff] [blame] | 436 | : file_(GetFileBasename(file)), |
| Dan Albert | ab5c882 | 2015-03-27 11:20:14 -0700 | [diff] [blame] | 437 | line_number_(line), |
| Dan Albert | ab5c882 | 2015-03-27 11:20:14 -0700 | [diff] [blame] | 438 | severity_(severity), |
| Tomasz Wasilczyk | a419de2 | 2017-12-18 06:30:17 -0800 | [diff] [blame] | 439 | tag_(tag), |
| 440 | error_(error) {} |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 441 | |
| 442 | const char* GetFile() const { |
| 443 | return file_; |
| 444 | } |
| 445 | |
| 446 | unsigned int GetLineNumber() const { |
| 447 | return line_number_; |
| 448 | } |
| 449 | |
| 450 | LogSeverity GetSeverity() const { |
| 451 | return severity_; |
| 452 | } |
| 453 | |
| Tomasz Wasilczyk | a419de2 | 2017-12-18 06:30:17 -0800 | [diff] [blame] | 454 | const char* GetTag() const { return tag_; } |
| 455 | |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 456 | int GetError() const { |
| 457 | return error_; |
| 458 | } |
| 459 | |
| 460 | std::ostream& GetBuffer() { |
| 461 | return buffer_; |
| 462 | } |
| 463 | |
| 464 | std::string ToString() const { |
| 465 | return buffer_.str(); |
| 466 | } |
| 467 | |
| 468 | private: |
| 469 | std::ostringstream buffer_; |
| 470 | const char* const file_; |
| 471 | const unsigned int line_number_; |
| 472 | const LogSeverity severity_; |
| Tomasz Wasilczyk | a419de2 | 2017-12-18 06:30:17 -0800 | [diff] [blame] | 473 | const char* const tag_; |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 474 | const int error_; |
| 475 | |
| 476 | DISALLOW_COPY_AND_ASSIGN(LogMessageData); |
| 477 | }; |
| 478 | |
| Tom Cherry | 46a2e0e | 2020-01-10 17:18:55 -0800 | [diff] [blame] | 479 | LogMessage::LogMessage(const char* file, unsigned int line, LogId, LogSeverity severity, |
| Tomasz Wasilczyk | a419de2 | 2017-12-18 06:30:17 -0800 | [diff] [blame] | 480 | const char* tag, int error) |
| Tom Cherry | 46a2e0e | 2020-01-10 17:18:55 -0800 | [diff] [blame] | 481 | : LogMessage(file, line, severity, tag, error) {} |
| 482 | |
| 483 | LogMessage::LogMessage(const char* file, unsigned int line, LogSeverity severity, const char* tag, |
| 484 | int error) |
| 485 | : data_(new LogMessageData(file, line, severity, tag, error)) {} |
| Tomasz Wasilczyk | a419de2 | 2017-12-18 06:30:17 -0800 | [diff] [blame] | 486 | |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 487 | LogMessage::~LogMessage() { |
| Andreas Gampe | c65ea94 | 2016-09-23 13:31:52 -0700 | [diff] [blame] | 488 | // Check severity again. This is duplicate work wrt/ LOG macros, but not LOG_STREAM. |
| Andreas Gampe | cb35a4a | 2016-09-23 16:37:12 -0700 | [diff] [blame] | 489 | if (!WOULD_LOG(data_->GetSeverity())) { |
| Andreas Gampe | c65ea94 | 2016-09-23 13:31:52 -0700 | [diff] [blame] | 490 | return; |
| 491 | } |
| 492 | |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 493 | // Finish constructing the message. |
| 494 | if (data_->GetError() != -1) { |
| 495 | data_->GetBuffer() << ": " << strerror(data_->GetError()); |
| 496 | } |
| 497 | std::string msg(data_->ToString()); |
| 498 | |
| Andreas Gampe | 2f9e49f | 2018-12-05 11:26:14 -0800 | [diff] [blame] | 499 | if (data_->GetSeverity() == FATAL) { |
| 500 | #ifdef __ANDROID__ |
| 501 | // Set the bionic abort message early to avoid liblog doing it |
| 502 | // with the individual lines, so that we get the whole message. |
| 503 | android_set_abort_message(msg.c_str()); |
| 504 | #endif |
| 505 | } |
| 506 | |
| Tom Cherry | a687242 | 2020-04-17 13:05:11 -0700 | [diff] [blame] | 507 | LogLine(data_->GetFile(), data_->GetLineNumber(), data_->GetSeverity(), data_->GetTag(), |
| 508 | msg.c_str()); |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 509 | |
| 510 | // Abort if necessary. |
| 511 | if (data_->GetSeverity() == FATAL) { |
| Jiyong Park | ecb6afe | 2020-08-10 21:27:51 +0900 | [diff] [blame] | 512 | if (__builtin_available(android 30, *)) { |
| 513 | __android_log_call_aborter(msg.c_str()); |
| Tom Cherry | 1bfa8ab | 2020-01-08 14:47:42 -0800 | [diff] [blame] | 514 | } else { |
| 515 | Aborter()(msg.c_str()); |
| 516 | } |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 517 | } |
| 518 | } |
| 519 | |
| 520 | std::ostream& LogMessage::stream() { |
| 521 | return data_->GetBuffer(); |
| 522 | } |
| 523 | |
| Tom Cherry | 46a2e0e | 2020-01-10 17:18:55 -0800 | [diff] [blame] | 524 | void LogMessage::LogLine(const char* file, unsigned int line, LogSeverity severity, const char* tag, |
| 525 | const char* message) { |
| Tom Cherry | 784ba9a | 2020-03-12 11:07:07 -0700 | [diff] [blame] | 526 | int32_t priority = LogSeverityToPriority(severity); |
| Jiyong Park | ecb6afe | 2020-08-10 21:27:51 +0900 | [diff] [blame] | 527 | if (__builtin_available(android 30, *)) { |
| Tom Cherry | 228eff1 | 2020-03-11 11:07:13 -0700 | [diff] [blame] | 528 | __android_log_message log_message = { |
| 529 | sizeof(__android_log_message), LOG_ID_DEFAULT, priority, tag, file, line, message}; |
| Jiyong Park | ecb6afe | 2020-08-10 21:27:51 +0900 | [diff] [blame] | 530 | __android_log_write_log_message(&log_message); |
| Andreas Gampe | fec5b09 | 2018-03-05 10:00:19 -0800 | [diff] [blame] | 531 | } else { |
| Tom Cherry | dbc07ce | 2020-01-22 07:48:42 -0800 | [diff] [blame] | 532 | if (tag == nullptr) { |
| 533 | std::lock_guard<std::recursive_mutex> lock(TagLock()); |
| 534 | if (gDefaultTag == nullptr) { |
| 535 | gDefaultTag = new std::string(getprogname()); |
| 536 | } |
| 537 | |
| 538 | Logger()(DEFAULT, severity, gDefaultTag->c_str(), file, line, message); |
| Tom Cherry | 1bfa8ab | 2020-01-08 14:47:42 -0800 | [diff] [blame] | 539 | } else { |
| 540 | Logger()(DEFAULT, severity, tag, file, line, message); |
| 541 | } |
| Andreas Gampe | fec5b09 | 2018-03-05 10:00:19 -0800 | [diff] [blame] | 542 | } |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 543 | } |
| 544 | |
| Elliott Hughes | 8cf75f0 | 2016-08-04 16:09:39 -0700 | [diff] [blame] | 545 | LogSeverity GetMinimumLogSeverity() { |
| Jiyong Park | ecb6afe | 2020-08-10 21:27:51 +0900 | [diff] [blame] | 546 | if (__builtin_available(android 30, *)) { |
| 547 | return PriorityToLogSeverity(__android_log_get_minimum_priority()); |
| Tom Cherry | 4916e09 | 2020-01-16 15:58:02 -0800 | [diff] [blame] | 548 | } else { |
| Elliott Hughes | 8cf75f0 | 2016-08-04 16:09:39 -0700 | [diff] [blame] | 549 | return gMinimumLogSeverity; |
| Tom Cherry | 4916e09 | 2020-01-16 15:58:02 -0800 | [diff] [blame] | 550 | } |
| 551 | } |
| 552 | |
| 553 | bool ShouldLog(LogSeverity severity, const char* tag) { |
| Tom Cherry | 4916e09 | 2020-01-16 15:58:02 -0800 | [diff] [blame] | 554 | // Even though we're not using the R liblog functions in this function, if we're running on Q, |
| 555 | // we need to fall back to using gMinimumLogSeverity, since __android_log_is_loggable() will not |
| 556 | // take into consideration the value from SetMinimumLogSeverity(). |
| Jiyong Park | ecb6afe | 2020-08-10 21:27:51 +0900 | [diff] [blame] | 557 | if (__builtin_available(android 30, *)) { |
| Tom Cherry | 784ba9a | 2020-03-12 11:07:07 -0700 | [diff] [blame] | 558 | int32_t priority = LogSeverityToPriority(severity); |
| Tom Cherry | 4916e09 | 2020-01-16 15:58:02 -0800 | [diff] [blame] | 559 | return __android_log_is_loggable(priority, tag, ANDROID_LOG_INFO); |
| 560 | } else { |
| 561 | return severity >= gMinimumLogSeverity; |
| 562 | } |
| Elliott Hughes | 8cf75f0 | 2016-08-04 16:09:39 -0700 | [diff] [blame] | 563 | } |
| 564 | |
| 565 | LogSeverity SetMinimumLogSeverity(LogSeverity new_severity) { |
| Jiyong Park | ecb6afe | 2020-08-10 21:27:51 +0900 | [diff] [blame] | 566 | if (__builtin_available(android 30, *)) { |
| Tom Cherry | 784ba9a | 2020-03-12 11:07:07 -0700 | [diff] [blame] | 567 | int32_t priority = LogSeverityToPriority(new_severity); |
| Jiyong Park | ecb6afe | 2020-08-10 21:27:51 +0900 | [diff] [blame] | 568 | return PriorityToLogSeverity(__android_log_set_minimum_priority(priority)); |
| Tom Cherry | 4916e09 | 2020-01-16 15:58:02 -0800 | [diff] [blame] | 569 | } else { |
| 570 | LogSeverity old_severity = gMinimumLogSeverity; |
| 571 | gMinimumLogSeverity = new_severity; |
| 572 | return old_severity; |
| 573 | } |
| Elliott Hughes | 8cf75f0 | 2016-08-04 16:09:39 -0700 | [diff] [blame] | 574 | } |
| 575 | |
| 576 | ScopedLogSeverity::ScopedLogSeverity(LogSeverity new_severity) { |
| 577 | old_ = SetMinimumLogSeverity(new_severity); |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 578 | } |
| 579 | |
| 580 | ScopedLogSeverity::~ScopedLogSeverity() { |
| Elliott Hughes | 8cf75f0 | 2016-08-04 16:09:39 -0700 | [diff] [blame] | 581 | SetMinimumLogSeverity(old_); |
| Dan Albert | e3ea058 | 2015-03-13 23:06:01 -0700 | [diff] [blame] | 582 | } |
| 583 | |
| 584 | } // namespace base |
| 585 | } // namespace android |