| 274 | #endif |
| 275 | |
| 276 | void InitLogging(char* argv[], LogFunction&& logger, AbortFunction&& aborter) { |
| 277 | SetLogger(std::forward<LogFunction>(logger)); |
| 278 | SetAborter(std::forward<AbortFunction>(aborter)); |
| 279 | |
| 280 | if (gInitialized) { |
| 281 | return; |
| 282 | } |
| 283 | |
| 284 | gInitialized = true; |
| 285 | |
| 286 | // Stash the command line for later use. We can use /proc/self/cmdline on |
| 287 | // Linux to recover this, but we don't have that luxury on the Mac/Windows, |
| 288 | // and there are a couple of argv[0] variants that are commonly used. |
| 289 | if (argv != nullptr) { |
| 290 | SetDefaultTag(basename(argv[0])); |
| 291 | } |
| 292 | |
| 293 | const char* tags = getenv("ANDROID_LOG_TAGS"); |
| 294 | if (tags == nullptr) { |
| 295 | return; |
| 296 | } |
| 297 | |
| 298 | std::vector<std::string> specs = Split(tags, " "); |
| 299 | for (size_t i = 0; i < specs.size(); ++i) { |
| 300 | // "tag-pattern:[vdiwefs]" |
| 301 | std::string spec(specs[i]); |
| 302 | if (spec.size() == 3 && StartsWith(spec, "*:")) { |
| 303 | switch (spec[2]) { |
| 304 | case 'v': |
| 305 | gMinimumLogSeverity = VERBOSE; |
| 306 | continue; |
| 307 | case 'd': |
| 308 | gMinimumLogSeverity = DEBUG; |
| 309 | continue; |
| 310 | case 'i': |
| 311 | gMinimumLogSeverity = INFO; |
| 312 | continue; |
| 313 | case 'w': |
| 314 | gMinimumLogSeverity = WARNING; |
| 315 | continue; |
| 316 | case 'e': |
| 317 | gMinimumLogSeverity = ERROR; |
| 318 | continue; |
| 319 | case 'f': |
| 320 | gMinimumLogSeverity = FATAL_WITHOUT_ABORT; |
| 321 | continue; |
| 322 | // liblog will even suppress FATAL if you say 's' for silent, but that's |
| 323 | // crazy! |
| 324 | case 's': |
| 325 | gMinimumLogSeverity = FATAL_WITHOUT_ABORT; |
| 326 | continue; |
| 327 | } |
| 328 | } |
| 329 | LOG(FATAL) << "unsupported '" << spec << "' in ANDROID_LOG_TAGS (" << tags |
| 330 | << ")"; |
| 331 | } |
| 332 | } |
| 333 |
nothing calls this directly
no test coverage detected