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

Side by Side Diff: base/logging.cc

Issue 2638763004: Report CHECK/DCHECK to test launcher summary output. (Closed)
Patch Set: Add stack trace marker. Created 3 years, 11 months 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
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/debug/activity_tracker.h" 10 #include "base/debug/activity_tracker.h"
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 void CloseLogFileUnlocked() { 335 void CloseLogFileUnlocked() {
336 if (!g_log_file) 336 if (!g_log_file)
337 return; 337 return;
338 338
339 CloseFile(g_log_file); 339 CloseFile(g_log_file);
340 g_log_file = nullptr; 340 g_log_file = nullptr;
341 } 341 }
342 342
343 } // namespace 343 } // namespace
344 344
345 const char kStackTraceMarker[] = "\nStack trace is below:\n";
Paweł Hajdan Jr. 2017/01/23 16:55:06 nit: Could you remove " is below" part?
alex-ac 2017/01/27 12:55:45 Done.
346
345 // This is never instantiated, it's just used for EAT_STREAM_PARAMETERS to have 347 // This is never instantiated, it's just used for EAT_STREAM_PARAMETERS to have
346 // an object of the correct type on the LHS of the unused part of the ternary 348 // an object of the correct type on the LHS of the unused part of the ternary
347 // operator. 349 // operator.
348 std::ostream* g_swallow_stream; 350 std::ostream* g_swallow_stream;
349 351
350 LoggingSettings::LoggingSettings() 352 LoggingSettings::LoggingSettings()
351 : logging_dest(LOG_DEFAULT), 353 : logging_dest(LOG_DEFAULT),
352 log_file(nullptr), 354 log_file(nullptr),
353 lock_log(LOCK_LOG_FILE), 355 lock_log(LOCK_LOG_FILE),
354 delete_old(APPEND_TO_OLD_LOG_FILE) {} 356 delete_old(APPEND_TO_OLD_LOG_FILE) {}
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 Init(file, line); 530 Init(file, line);
529 stream_ << "Check failed: " << *result; 531 stream_ << "Check failed: " << *result;
530 delete result; 532 delete result;
531 } 533 }
532 534
533 LogMessage::~LogMessage() { 535 LogMessage::~LogMessage() {
534 #if !defined(OFFICIAL_BUILD) && !defined(OS_NACL) && !defined(__UCLIBC__) 536 #if !defined(OFFICIAL_BUILD) && !defined(OS_NACL) && !defined(__UCLIBC__)
535 if (severity_ == LOG_FATAL && !base::debug::BeingDebugged()) { 537 if (severity_ == LOG_FATAL && !base::debug::BeingDebugged()) {
536 // Include a stack trace on a fatal, unless a debugger is attached. 538 // Include a stack trace on a fatal, unless a debugger is attached.
537 base::debug::StackTrace trace; 539 base::debug::StackTrace trace;
538 stream_ << std::endl; // Newline to separate from log message. 540 // Write marker to separate stack trace from message.
541 stream_ << kStackTraceMarker;
539 trace.OutputToStream(&stream_); 542 trace.OutputToStream(&stream_);
540 } 543 }
541 #endif 544 #endif
542 stream_ << std::endl; 545 stream_ << std::endl;
543 std::string str_newline(stream_.str()); 546 std::string str_newline(stream_.str());
544 547
545 // Give any log message handler first dibs on the message. 548 // Give any log message handler first dibs on the message.
546 if (log_message_handler && 549 if (log_message_handler &&
547 log_message_handler(severity_, file_, line_, 550 log_message_handler(severity_, file_, line_,
548 message_start_, str_newline)) { 551 message_start_, str_newline)) {
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 BASE_EXPORT void LogErrorNotReached(const char* file, int line) { 950 BASE_EXPORT void LogErrorNotReached(const char* file, int line) {
948 LogMessage(file, line, LOG_ERROR).stream() 951 LogMessage(file, line, LOG_ERROR).stream()
949 << "NOTREACHED() hit."; 952 << "NOTREACHED() hit.";
950 } 953 }
951 954
952 } // namespace logging 955 } // namespace logging
953 956
954 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) { 957 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) {
955 return out << (wstr ? base::WideToUTF8(wstr) : std::string()); 958 return out << (wstr ? base::WideToUTF8(wstr) : std::string());
956 } 959 }
OLDNEW
« no previous file with comments | « base/logging.h ('k') | base/logging_unittest.cc » ('j') | base/test/test_suite.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698