Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Unified Diff: components/crash/content/app/crashpad.cc

Issue 2497833002: support multiple log message handlers in base/logging.h (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/crash/content/app/breakpad_mac.mm ('k') | components/proximity_auth/logging/logging_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/crash/content/app/crashpad.cc
diff --git a/components/crash/content/app/crashpad.cc b/components/crash/content/app/crashpad.cc
index 76f67348ab0fcb6cd0e7ed3412a410d31be569da..5d9753b5ed4b48bab92ae680617ad43a15dc308e 100644
--- a/components/crash/content/app/crashpad.cc
+++ b/components/crash/content/app/crashpad.cc
@@ -53,9 +53,8 @@ void ClearCrashKey(const base::StringPiece& key) {
}
bool LogMessageHandler(int severity,
- const char* file,
+ const std::string& file,
int line,
- size_t message_start,
const std::string& string) {
// Only handle FATAL.
if (severity != logging::LOG_FATAL) {
@@ -73,16 +72,15 @@ bool LogMessageHandler(int severity,
base::AutoReset<bool> guard(&guarded, true);
// Only log last path component. This matches logging.cc.
- if (file) {
- const char* slash = strrchr(file, '/');
- if (slash) {
- file = slash + 1;
- }
- }
-
- CHECK_LE(message_start, string.size());
- std::string message = base::StringPrintf("%s:%d: %s", file, line,
- string.c_str() + message_start);
+ size_t last_slash = file.rfind('/');
+ if (last_slash == file.npos)
+ last_slash = 0;
+ else
+ last_slash++;
+
+ std::string message = base::StringPrintf("%s:%d: %s",
+ file.substr(last_slash).c_str(),
+ line, string.c_str());
SetCrashKeyValue("LOG_FATAL", message);
// Rather than including the code to force the crash here, allow the caller to
@@ -164,7 +162,7 @@ void InitializeCrashpadImpl(bool initial_client,
SetCrashKeyValue("pid", base::IntToString(::GetCurrentProcessId()));
#endif
- logging::SetLogMessageHandler(LogMessageHandler);
+ logging::AddLogMessageHandler(LogMessageHandler);
// If clients called CRASHPAD_SIMULATE_CRASH() instead of
// base::debug::DumpWithoutCrashing(), these dumps would appear as crashes in
« no previous file with comments | « components/crash/content/app/breakpad_mac.mm ('k') | components/proximity_auth/logging/logging_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698