diff options
author | Yabin Cui <yabinc@google.com> | 2015-09-18 11:10:55 -0700 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2015-09-21 11:46:16 -0700 |
commit | 42aa127e8ab4c5eb5197cf3cc68470cf3a0fdcbb (patch) | |
tree | 55b7c1c506dfd1376136456b847aca8933eee8d5 /simpleperf | |
parent | 12f454e24a518d81fe42043b7142582b81694363 (diff) | |
download | extras-42aa127e8ab4c5eb5197cf3cc68470cf3a0fdcbb.tar.gz |
Simpleperf: rewrite unsupported logging style.
Previously we can use a ternary operator to choose the log level, like
(error ? LOG(ERROR) : LOG(DEBUG)) << xxx. But as the LOG() macro is about
to change, we can no longer write like this.
This CL also changes some improper log levels and log messages.
Change-Id: Ib9a55f2ca241516a6e89afad4a733cc07b19570f
Diffstat (limited to 'simpleperf')
-rw-r--r-- | simpleperf/event_fd.cpp | 19 | ||||
-rw-r--r-- | simpleperf/event_type.cpp | 4 | ||||
-rw-r--r-- | simpleperf/workload.cpp | 10 |
3 files changed, 22 insertions, 11 deletions
diff --git a/simpleperf/event_fd.cpp b/simpleperf/event_fd.cpp index 9c5e4ab6..29be60fa 100644 --- a/simpleperf/event_fd.cpp +++ b/simpleperf/event_fd.cpp @@ -48,14 +48,23 @@ std::unique_ptr<EventFd> EventFd::OpenEventFile(const perf_event_attr& attr, pid } int perf_event_fd = perf_event_open(&perf_attr, tid, cpu, -1, 0); if (perf_event_fd == -1) { - (report_error ? PLOG(ERROR) : PLOG(DEBUG)) << "open perf_event_file (event " << event_name - << ", tid " << tid << ", cpu " << cpu << ") failed"; + if (report_error) { + PLOG(ERROR) << "open perf_event_file (event " << event_name << ", tid " << tid << ", cpu " + << cpu << ") failed"; + } else { + PLOG(DEBUG) << "open perf_event_file (event " << event_name << ", tid " << tid << ", cpu " + << cpu << ") failed"; + } return nullptr; } if (fcntl(perf_event_fd, F_SETFD, FD_CLOEXEC) == -1) { - (report_error ? PLOG(ERROR) : PLOG(DEBUG)) << "fcntl(FD_CLOEXEC) for perf_event_file (event " - << event_name << ", tid " << tid << ", cpu " << cpu - << ") failed"; + if (report_error) { + PLOG(ERROR) << "fcntl(FD_CLOEXEC) for perf_event_file (event " << event_name << ", tid " + << tid << ", cpu " << cpu << ") failed"; + } else { + PLOG(DEBUG) << "fcntl(FD_CLOEXEC) for perf_event_file (event " << event_name << ", tid " + << tid << ", cpu " << cpu << ") failed"; + } return nullptr; } return std::unique_ptr<EventFd>(new EventFd(perf_event_fd, event_name, tid, cpu)); diff --git a/simpleperf/event_type.cpp b/simpleperf/event_type.cpp index 1d0243c7..4f139792 100644 --- a/simpleperf/event_type.cpp +++ b/simpleperf/event_type.cpp @@ -28,9 +28,7 @@ #include "event_fd.h" #include "utils.h" -#define EVENT_TYPE_TABLE_ENTRY(name, type, config) \ - { name, type, config } \ - , +#define EVENT_TYPE_TABLE_ENTRY(name, type, config) {name, type, config}, static const std::vector<EventType> static_event_type_array = { #include "event_type_table.h" diff --git a/simpleperf/workload.cpp b/simpleperf/workload.cpp index 9138afa5..42a5fddd 100644 --- a/simpleperf/workload.cpp +++ b/simpleperf/workload.cpp @@ -108,9 +108,9 @@ static void ChildProcessFn(std::vector<std::string>& args, int start_signal_fd, TEMP_FAILURE_RETRY(write(exec_child_fd, &exec_child_failed, 1)); close(exec_child_fd); errno = saved_errno; - PLOG(FATAL) << "execvp(" << argv[0] << ") failed"; + PLOG(ERROR) << "child process failed to execvp(" << argv[0] << ")"; } else { - PLOG(FATAL) << "child process failed to receive start_signal, nread = " << nread; + PLOG(ERROR) << "child process failed to receive start_signal, nread = " << nread; } } @@ -125,7 +125,11 @@ bool Workload::Start() { char exec_child_failed; ssize_t nread = TEMP_FAILURE_RETRY(read(exec_child_fd_, &exec_child_failed, 1)); if (nread != 0) { - ((nread == -1) ? PLOG(ERROR) : LOG(ERROR)) << "exec child failed, nread = " << nread; + if (nread == -1) { + PLOG(ERROR) << "failed to receive error message from child process"; + } else { + LOG(ERROR) << "received error message from child process"; + } return false; } work_state_ = Started; |