OLD | NEW |
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 #include <cstring> | 52 #include <cstring> |
53 #include <ctime> | 53 #include <ctime> |
54 #include <iomanip> | 54 #include <iomanip> |
55 #include <ostream> | 55 #include <ostream> |
56 #include <string> | 56 #include <string> |
57 | 57 |
58 #include "base/base_switches.h" | 58 #include "base/base_switches.h" |
59 #include "base/command_line.h" | 59 #include "base/command_line.h" |
60 #include "base/debug/alias.h" | 60 #include "base/debug/alias.h" |
61 #include "base/debug/debugger.h" | 61 #include "base/debug/debugger.h" |
| 62 #include "base/debug/dump_without_crashing.h" |
62 #include "base/debug/stack_trace.h" | 63 #include "base/debug/stack_trace.h" |
63 #include "base/posix/eintr_wrapper.h" | 64 #include "base/posix/eintr_wrapper.h" |
64 #include "base/strings/string_piece.h" | 65 #include "base/strings/string_piece.h" |
65 #include "base/strings/string_util.h" | 66 #include "base/strings/string_util.h" |
66 #include "base/strings/stringprintf.h" | 67 #include "base/strings/stringprintf.h" |
67 #include "base/strings/sys_string_conversions.h" | 68 #include "base/strings/sys_string_conversions.h" |
68 #include "base/strings/utf_string_conversions.h" | 69 #include "base/strings/utf_string_conversions.h" |
69 #include "base/synchronization/lock_impl.h" | 70 #include "base/synchronization/lock_impl.h" |
70 #include "base/threading/platform_thread.h" | 71 #include "base/threading/platform_thread.h" |
71 #include "base/vlog.h" | 72 #include "base/vlog.h" |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 void CloseLogFileUnlocked() { | 327 void CloseLogFileUnlocked() { |
327 if (!g_log_file) | 328 if (!g_log_file) |
328 return; | 329 return; |
329 | 330 |
330 CloseFile(g_log_file); | 331 CloseFile(g_log_file); |
331 g_log_file = nullptr; | 332 g_log_file = nullptr; |
332 } | 333 } |
333 | 334 |
334 } // namespace | 335 } // namespace |
335 | 336 |
| 337 #if defined(DCHECK_IS_DUMP_WITHOUT_CRASH) |
| 338 // Used to implement dump-on-DCHECK. See crbug.com/596231. |
| 339 void DCheckDumpWithoutCrashing() { |
| 340 // To ensure we don't risk spamming Crash with dump-on-DCHECK reports we log |
| 341 // only the first[*] DCHECK to fail once DumpWithoutCrashing() is working. |
| 342 // [*] This is racey, but in the pathological case still only results in one |
| 343 // dump per-racing-thread, rather than our aim of one per-process. |
| 344 static bool dump_on_dcheck = true; |
| 345 if (dump_on_dcheck) |
| 346 dump_on_dcheck = !base::debug::DumpWithoutCrashing(); |
| 347 } |
| 348 #endif |
| 349 |
336 LoggingSettings::LoggingSettings() | 350 LoggingSettings::LoggingSettings() |
337 : logging_dest(LOG_DEFAULT), | 351 : logging_dest(LOG_DEFAULT), |
338 log_file(nullptr), | 352 log_file(nullptr), |
339 lock_log(LOCK_LOG_FILE), | 353 lock_log(LOCK_LOG_FILE), |
340 delete_old(APPEND_TO_OLD_LOG_FILE) {} | 354 delete_old(APPEND_TO_OLD_LOG_FILE) {} |
341 | 355 |
342 bool BaseInitLoggingImpl(const LoggingSettings& settings) { | 356 bool BaseInitLoggingImpl(const LoggingSettings& settings) { |
343 #if defined(OS_NACL) | 357 #if defined(OS_NACL) |
344 // Can log only to the system debug log. | 358 // Can log only to the system debug log. |
345 CHECK_EQ(settings.logging_dest & ~LOG_TO_SYSTEM_DEBUG_LOG, 0); | 359 CHECK_EQ(settings.logging_dest & ~LOG_TO_SYSTEM_DEBUG_LOG, 0); |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 BASE_EXPORT void LogErrorNotReached(const char* file, int line) { | 922 BASE_EXPORT void LogErrorNotReached(const char* file, int line) { |
909 LogMessage(file, line, LOG_ERROR).stream() | 923 LogMessage(file, line, LOG_ERROR).stream() |
910 << "NOTREACHED() hit."; | 924 << "NOTREACHED() hit."; |
911 } | 925 } |
912 | 926 |
913 } // namespace logging | 927 } // namespace logging |
914 | 928 |
915 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) { | 929 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) { |
916 return out << (wstr ? base::WideToUTF8(wstr) : std::string()); | 930 return out << (wstr ? base::WideToUTF8(wstr) : std::string()); |
917 } | 931 } |
OLD | NEW |