win: Don't log wide strings via path.value().c_str()

At the moment the LOGs print something unhelpful like:

[19912:21888:20150501,145958.098:ERROR file_io_win.cc:122] CreateFile 000000C9F8FDE7F0: The system cannot find the file specified.  (0x2)

(where the hex string ought to be a file name)

R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/1117393002
This commit is contained in:
Scott Graham 2015-05-01 15:49:35 -07:00
parent dfaa25af49
commit d8713a576b
3 changed files with 12 additions and 9 deletions

View File

@ -446,7 +446,7 @@ void Metadata::Write() {
const base::FilePath& path = report.file_path;
if (path.DirName() != report_dir_) {
LOG(ERROR) << path.value().c_str() << " expected to start with "
<< report_dir_.value().c_str();
<< base::UTF16ToUTF8(report_dir_.value());
return;
}
records.push_back(MetadataFileReportRecord(report, &string_table));
@ -626,7 +626,8 @@ OperationStatus CrashReportDatabaseWin::ErrorWritingCrashReport(
// We failed to write, so remove the dump file. There's no entry in the
// metadata table yet.
if (!DeleteFile(scoped_report->path.value().c_str())) {
PLOG(ERROR) << "DeleteFile " << scoped_report->path.value().c_str();
PLOG(ERROR) << "DeleteFile "
<< base::UTF16ToUTF8(scoped_report->path.value());
return CrashReportDatabase::kFileSystemError;
}

View File

@ -15,6 +15,7 @@
#include "snapshot/crashpad_info_client_options.h"
#include "base/files/file_path.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "client/crashpad_info.h"
#include "gtest/gtest.h"
@ -167,9 +168,9 @@ TEST(CrashpadInfoClientOptions, TwoModules) {
<< dlerror();
#elif defined(OS_WIN)
ScopedDlHandle dl_handle(LoadLibrary(module_path.value().c_str()));
ASSERT_TRUE(dl_handle.valid()) << "LoadLibrary "
<< module_path.value().c_str() << ": "
<< ErrorMessage();
ASSERT_TRUE(dl_handle.valid())
<< "LoadLibrary " << base::UTF16ToUTF8(module_path.value()) << ": "
<< ErrorMessage();
#else
#error Port.
#endif // OS_MACOSX

View File

@ -17,6 +17,7 @@
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/utf_string_conversions.h"
namespace {
@ -59,8 +60,8 @@ FileHandle LoggingOpenFileForOutput(DWORD access,
disposition,
FILE_ATTRIBUTE_NORMAL,
nullptr);
PLOG_IF(ERROR, file == INVALID_HANDLE_VALUE) << "CreateFile "
<< path.value().c_str();
PLOG_IF(ERROR, file == INVALID_HANDLE_VALUE)
<< "CreateFile " << base::UTF16ToUTF8(path.value());
return file;
}
@ -119,8 +120,8 @@ FileHandle LoggingOpenFileForRead(const base::FilePath& path) {
OPEN_EXISTING,
0,
nullptr);
PLOG_IF(ERROR, file == INVALID_HANDLE_VALUE) << "CreateFile "
<< path.value().c_str();
PLOG_IF(ERROR, file == INVALID_HANDLE_VALUE)
<< "CreateFile " << base::UTF16ToUTF8(path.value());
return file;
}