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

Side by Side Diff: base/logging.cc

Issue 2377963002: restore LOG_FATAL crash key on windows
Patch Set: move CrashMessageHandler out of base 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 unified diff | Download patch
« no previous file with comments | « base/logging.h ('k') | blimp/engine/app/blimp_engine_crash_keys.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/logging.h" 5 #include "base/logging.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 119
120 // Should we pop up fatal debug messages in a dialog? 120 // Should we pop up fatal debug messages in a dialog?
121 bool show_error_dialogs = false; 121 bool show_error_dialogs = false;
122 122
123 // An assert handler override specified by the client to be called instead of 123 // An assert handler override specified by the client to be called instead of
124 // the debug message dialog and process termination. 124 // the debug message dialog and process termination.
125 LogAssertHandlerFunction log_assert_handler = nullptr; 125 LogAssertHandlerFunction log_assert_handler = nullptr;
126 // A log message handler that gets notified of every log message we process. 126 // A log message handler that gets notified of every log message we process.
127 LogMessageHandlerFunction log_message_handler = nullptr; 127 LogMessageHandlerFunction log_message_handler = nullptr;
128 128
129 CrashMessageHandlerFunction crash_message_handler = nullptr;
130
129 // Helper functions to wrap platform differences. 131 // Helper functions to wrap platform differences.
130 132
131 int32_t CurrentProcessId() { 133 int32_t CurrentProcessId() {
132 #if defined(OS_WIN) 134 #if defined(OS_WIN)
133 return GetCurrentProcessId(); 135 return GetCurrentProcessId();
134 #elif defined(OS_POSIX) 136 #elif defined(OS_POSIX)
135 return getpid(); 137 return getpid();
136 #endif 138 #endif
137 } 139 }
138 140
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 } 446 }
445 447
446 void SetLogMessageHandler(LogMessageHandlerFunction handler) { 448 void SetLogMessageHandler(LogMessageHandlerFunction handler) {
447 log_message_handler = handler; 449 log_message_handler = handler;
448 } 450 }
449 451
450 LogMessageHandlerFunction GetLogMessageHandler() { 452 LogMessageHandlerFunction GetLogMessageHandler() {
451 return log_message_handler; 453 return log_message_handler;
452 } 454 }
453 455
456 void SetCrashMessageHandler(CrashMessageHandlerFunction handler) {
457 crash_message_handler = handler;
458 }
459
454 // Explicit instantiations for commonly used comparisons. 460 // Explicit instantiations for commonly used comparisons.
455 template std::string* MakeCheckOpString<int, int>( 461 template std::string* MakeCheckOpString<int, int>(
456 const int&, const int&, const char* names); 462 const int&, const int&, const char* names);
457 template std::string* MakeCheckOpString<unsigned long, unsigned long>( 463 template std::string* MakeCheckOpString<unsigned long, unsigned long>(
458 const unsigned long&, const unsigned long&, const char* names); 464 const unsigned long&, const unsigned long&, const char* names);
459 template std::string* MakeCheckOpString<unsigned long, unsigned int>( 465 template std::string* MakeCheckOpString<unsigned long, unsigned int>(
460 const unsigned long&, const unsigned int&, const char* names); 466 const unsigned long&, const unsigned int&, const char* names);
461 template std::string* MakeCheckOpString<unsigned int, unsigned long>( 467 template std::string* MakeCheckOpString<unsigned int, unsigned long>(
462 const unsigned int&, const unsigned long&, const char* names); 468 const unsigned int&, const unsigned long&, const char* names);
463 template std::string* MakeCheckOpString<std::string, std::string>( 469 template std::string* MakeCheckOpString<std::string, std::string>(
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 if (severity_ == LOG_FATAL && !base::debug::BeingDebugged()) { 536 if (severity_ == LOG_FATAL && !base::debug::BeingDebugged()) {
531 // Include a stack trace on a fatal, unless a debugger is attached. 537 // Include a stack trace on a fatal, unless a debugger is attached.
532 base::debug::StackTrace trace; 538 base::debug::StackTrace trace;
533 stream_ << std::endl; // Newline to separate from log message. 539 stream_ << std::endl; // Newline to separate from log message.
534 trace.OutputToStream(&stream_); 540 trace.OutputToStream(&stream_);
535 } 541 }
536 #endif 542 #endif
537 stream_ << std::endl; 543 stream_ << std::endl;
538 std::string str_newline(stream_.str()); 544 std::string str_newline(stream_.str());
539 545
546 if (severity_ == LOG_FATAL && crash_message_handler)
547 crash_message_handler(str_newline.c_str() + message_start_);
548
540 // Give any log message handler first dibs on the message. 549 // Give any log message handler first dibs on the message.
541 if (log_message_handler && 550 if (log_message_handler &&
542 log_message_handler(severity_, file_, line_, 551 log_message_handler(severity_, file_, line_,
543 message_start_, str_newline)) { 552 message_start_, str_newline)) {
544 // The handler took care of it, no further processing. 553 // The handler took care of it, no further processing.
545 return; 554 return;
546 } 555 }
547 556
548 if ((g_logging_destination & LOG_TO_SYSTEM_DEBUG_LOG) != 0) { 557 if ((g_logging_destination & LOG_TO_SYSTEM_DEBUG_LOG) != 0) {
549 #if defined(OS_WIN) 558 #if defined(OS_WIN)
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 BASE_EXPORT void LogErrorNotReached(const char* file, int line) { 930 BASE_EXPORT void LogErrorNotReached(const char* file, int line) {
922 LogMessage(file, line, LOG_ERROR).stream() 931 LogMessage(file, line, LOG_ERROR).stream()
923 << "NOTREACHED() hit."; 932 << "NOTREACHED() hit.";
924 } 933 }
925 934
926 } // namespace logging 935 } // namespace logging
927 936
928 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) { 937 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) {
929 return out << (wstr ? base::WideToUTF8(wstr) : std::string()); 938 return out << (wstr ? base::WideToUTF8(wstr) : std::string());
930 } 939 }
OLDNEW
« no previous file with comments | « base/logging.h ('k') | blimp/engine/app/blimp_engine_crash_keys.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698