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