diff options
author | d.samantaray <d.samantaray@samsung.com> | 2015-04-16 21:29:03 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-17 04:29:12 +0000 |
commit | 3d79d785171cf4cb0cbdf934b4690e10d93853b4 (patch) | |
tree | 35f96f800f3ec4f99ddca7ee5aeb376a09b1006f /components/metrics | |
parent | 553a2f6a357784380b09f6950ece12aeb89e71be (diff) | |
download | chromium_src-3d79d785171cf4cb0cbdf934b4690e10d93853b4.zip chromium_src-3d79d785171cf4cb0cbdf934b4690e10d93853b4.tar.gz chromium_src-3d79d785171cf4cb0cbdf934b4690e10d93853b4.tar.bz2 |
Add output of error code for file operations in serialization_utils.cc.
Add error number (errno) to the logging of lock/unlock/open operations to improve log output verbosity.
BUG=467586
Please review.
Review URL: https://codereview.chromium.org/1060913003
Cr-Commit-Position: refs/heads/master@{#325596}
Diffstat (limited to 'components/metrics')
-rw-r--r-- | components/metrics/serialization/serialization_utils.cc | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/components/metrics/serialization/serialization_utils.cc b/components/metrics/serialization/serialization_utils.cc index d57b51b..5f03fe7 100644 --- a/components/metrics/serialization/serialization_utils.cc +++ b/components/metrics/serialization/serialization_utils.cc @@ -122,7 +122,7 @@ void SerializationUtils::ReadAndTruncateMetricsFromFile( result = stat(filename.c_str(), &stat_buf); if (result < 0) { if (errno != ENOENT) - DPLOG(ERROR) << filename << ": bad metrics file stat"; + DPLOG(ERROR) << "bad metrics file stat: " << filename; // Nothing to collect---try later. return; @@ -133,12 +133,12 @@ void SerializationUtils::ReadAndTruncateMetricsFromFile( } base::ScopedFD fd(open(filename.c_str(), O_RDWR)); if (fd.get() < 0) { - DPLOG(ERROR) << filename << ": cannot open"; + DPLOG(ERROR) << "cannot open: " << filename; return; } result = flock(fd.get(), LOCK_EX); if (result < 0) { - DPLOG(ERROR) << filename << ": cannot lock"; + DPLOG(ERROR) << "cannot lock: " << filename; return; } @@ -157,11 +157,11 @@ void SerializationUtils::ReadAndTruncateMetricsFromFile( result = ftruncate(fd.get(), 0); if (result < 0) - DPLOG(ERROR) << "truncate metrics log"; + DPLOG(ERROR) << "truncate metrics log: " << filename; result = flock(fd.get(), LOCK_UN); if (result < 0) - DPLOG(ERROR) << "unlock metrics log"; + DPLOG(ERROR) << "unlock metrics log: " << filename; } bool SerializationUtils::WriteMetricToFile(const MetricSample& sample, @@ -174,7 +174,7 @@ bool SerializationUtils::WriteMetricToFile(const MetricSample& sample, READ_WRITE_ALL_FILE_FLAGS)); if (file_descriptor.get() < 0) { - DLOG(ERROR) << "error openning the file"; + DPLOG(ERROR) << "error openning the file: " << filename; return false; } @@ -183,14 +183,14 @@ bool SerializationUtils::WriteMetricToFile(const MetricSample& sample, // underneath us. Keep the file locked as briefly as possible. // Freeing file_descriptor will close the file and and remove the lock. if (HANDLE_EINTR(flock(file_descriptor.get(), LOCK_EX)) < 0) { - DLOG(ERROR) << "error locking" << filename << " : " << errno; + DPLOG(ERROR) << "error locking: " << filename; return false; } std::string msg = sample.ToString(); int32 size = msg.length() + sizeof(int32); if (size > kMessageMaxLength) { - DLOG(ERROR) << "cannot write message: too long"; + DPLOG(ERROR) << "cannot write message: too long: " << filename; return false; } @@ -199,13 +199,13 @@ bool SerializationUtils::WriteMetricToFile(const MetricSample& sample, if (!base::WriteFileDescriptor(file_descriptor.get(), reinterpret_cast<char*>(&size), sizeof(size))) { - DPLOG(ERROR) << "error writing message length"; + DPLOG(ERROR) << "error writing message length: " << filename; return false; } if (!base::WriteFileDescriptor( file_descriptor.get(), msg.c_str(), msg.size())) { - DPLOG(ERROR) << "error writing message"; + DPLOG(ERROR) << "error writing message: " << filename; return false; } |