libbase-use-own-logging.patch
| 1 | From e5dd71a290f664d3f3bf0dd8a4bad411dc7ad416 Mon Sep 17 00:00:00 2001 |
| 2 | From: Elliott Hughes <enh@google.com> |
| 3 | Date: Thu, 28 Jul 2016 15:15:28 -0700 |
| 4 | Subject: [PATCH] libbase should use its own logging! |
| 5 | |
| 6 | Not doing so led to us using a bogus log tag. |
| 7 | |
| 8 | Bug: http://b/30281203 |
| 9 | Change-Id: I3ac91758a1a043146c65f2ae0f36fcfbe372c30f |
| 10 | --- |
| 11 | base/file.cpp | 11 +++++------ |
| 12 | base/logging.cpp | 3 +-- |
| 13 | 2 files changed, 6 insertions(+), 8 deletions(-) |
| 14 | |
| 15 | diff --git a/base/file.cpp b/base/file.cpp |
| 16 | index da1adba19..4e7ac82d1 100644 |
| 17 | --- a/base/file.cpp |
| 18 | +++ b/base/file.cpp |
| 19 | @@ -24,9 +24,8 @@ |
| 20 | #include <string> |
| 21 | |
| 22 | #include "android-base/macros.h" // For TEMP_FAILURE_RETRY on Darwin. |
| 23 | +#include "android-base/logging.h" |
| 24 | #include "android-base/utf8.h" |
| 25 | -#define LOG_TAG "base.file" |
| 26 | -#include "cutils/log.h" |
| 27 | #include "utils/Compat.h" |
| 28 | |
| 29 | namespace android { |
| 30 | @@ -86,22 +85,22 @@ bool WriteStringToFile(const std::string& content, const std::string& path, |
| 31 | int flags = O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NOFOLLOW | O_BINARY; |
| 32 | int fd = TEMP_FAILURE_RETRY(open(path.c_str(), flags, mode)); |
| 33 | if (fd == -1) { |
| 34 | - ALOGE("android::WriteStringToFile open failed: %s", strerror(errno)); |
| 35 | + PLOG(ERROR) << "android::WriteStringToFile open failed"; |
| 36 | return false; |
| 37 | } |
| 38 | |
| 39 | // We do an explicit fchmod here because we assume that the caller really |
| 40 | // meant what they said and doesn't want the umask-influenced mode. |
| 41 | if (fchmod(fd, mode) == -1) { |
| 42 | - ALOGE("android::WriteStringToFile fchmod failed: %s", strerror(errno)); |
| 43 | + PLOG(ERROR) << "android::WriteStringToFile fchmod failed"; |
| 44 | return CleanUpAfterFailedWrite(path); |
| 45 | } |
| 46 | if (fchown(fd, owner, group) == -1) { |
| 47 | - ALOGE("android::WriteStringToFile fchown failed: %s", strerror(errno)); |
| 48 | + PLOG(ERROR) << "android::WriteStringToFile fchown failed"; |
| 49 | return CleanUpAfterFailedWrite(path); |
| 50 | } |
| 51 | if (!WriteStringToFd(content, fd)) { |
| 52 | - ALOGE("android::WriteStringToFile write failed: %s", strerror(errno)); |
| 53 | + PLOG(ERROR) << "android::WriteStringToFile write failed"; |
| 54 | return CleanUpAfterFailedWrite(path); |
| 55 | } |
| 56 | close(fd); |
| 57 | diff --git a/base/logging.cpp b/base/logging.cpp |
| 58 | index 769c266c9..959bb8b05 100644 |
| 59 | --- a/base/logging.cpp |
| 60 | +++ b/base/logging.cpp |
| 61 | @@ -43,12 +43,11 @@ |
| 62 | |
| 63 | #include "android-base/macros.h" |
| 64 | #include "android-base/strings.h" |
| 65 | -#include "cutils/threads.h" |
| 66 | |
| 67 | // Headers for LogMessage::LogLine. |
| 68 | #ifdef __ANDROID__ |
| 69 | #include <android/set_abort_message.h> |
| 70 | -#include "cutils/log.h" |
| 71 | +#include "log/log.h" |
| 72 | #else |
| 73 | #include <sys/types.h> |
| 74 | #include <unistd.h> |
| 75 | -- |
| 76 | 2.11.0 |
| 77 | |
| 78 |