Skip to content

Commit

Permalink
Just some basic changes instead of the new version
Browse files Browse the repository at this point in the history
  • Loading branch information
noeffn committed Jan 18, 2020
1 parent 50c42a3 commit 33ee06d
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions base/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,23 @@ LogMessageHandlerFunction GetLogMessageHandler() {

#if defined(OS_WIN)
std::string SystemErrorCodeToString(unsigned long error_code) {
const int kErrorMessageBufferSize = 256;
char msgbuf[kErrorMessageBufferSize];
DWORD flags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS;
DWORD len = FormatMessageA(flags, nullptr, error_code, 0, msgbuf,
base::size(msgbuf), nullptr);
char msgbuf[256];
DWORD flags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_MAX_WIDTH_MASK;
DWORD len = FormatMessageA(
flags, nullptr, error_code, 0, msgbuf, arraysize(msgbuf), nullptr);
if (len) {
// Messages returned by system end with line breaks.
return base::CollapseWhitespaceASCII(msgbuf, true) +
base::StringPrintf(" (0x%lX)", error_code);
// Most system messages end in a period and a space. Remove the space if
// it’s there, because the following StringPrintf() includes one.
if (len >= 1 && msgbuf[len - 1] == ' ') {
msgbuf[len - 1] = '\0';
}
return base::StringPrintf("%s (%u)",
msgbuf, error_code);
}
return base::StringPrintf("Error (0x%lX) while retrieving error. (0x%lX)",
GetLastError(), error_code);
return base::StringPrintf("Error %u while retrieving error %u",
GetLastError(),
error_code);
}
#endif // OS_WIN

Expand Down Expand Up @@ -265,7 +270,7 @@ LogMessage::~LogMessage() {
#endif
}
#elif defined(OS_WIN)
OutputDebugStringA(str_newline.c_str());
OutputDebugString(str_newline.c_str());
#endif // OS_MACOSX

if (severity_ == LOG_FATAL) {
Expand Down

0 comments on commit 33ee06d

Please sign in to comment.