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

Side by Side Diff: gpu/command_buffer/service/logger.cc

Issue 16042005: Prepend the log prefix everywhere (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « gpu/command_buffer/service/error_state.cc ('k') | no next file » | 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "gpu/command_buffer/service/logger.h" 5 #include "gpu/command_buffer/service/logger.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "gpu/command_buffer/common/debug_marker_manager.h" 10 #include "gpu/command_buffer/common/debug_marker_manager.h"
11 #include "gpu/command_buffer/service/gpu_switches.h" 11 #include "gpu/command_buffer/service/gpu_switches.h"
12 12
13 namespace gpu { 13 namespace gpu {
14 namespace gles2 { 14 namespace gles2 {
15 15
16 Logger::Logger(const DebugMarkerManager* debug_marker_manager) 16 Logger::Logger(const DebugMarkerManager* debug_marker_manager)
17 : debug_marker_manager_(debug_marker_manager), 17 : debug_marker_manager_(debug_marker_manager),
18 log_message_count_(0), 18 log_message_count_(0),
19 log_synthesized_gl_errors_(true) { 19 log_synthesized_gl_errors_(true) {
20 Logger* this_temp = this; 20 Logger* this_temp = this;
21 this_in_hex_ = base::HexEncode(&this_temp, sizeof(this_temp)); 21 this_in_hex_ = std::string("GroupMarkerNotSet(crbug.com/242999)!:") +
22 base::HexEncode(&this_temp, sizeof(this_temp));
22 } 23 }
23 24
24 Logger::~Logger() {} 25 Logger::~Logger() {}
25 26
26 void Logger::LogMessage( 27 void Logger::LogMessage(
27 const char* filename, int line, const std::string& msg) { 28 const char* filename, int line, const std::string& msg) {
28 if (log_message_count_ < kMaxLogMessages || 29 if (log_message_count_ < kMaxLogMessages ||
29 CommandLine::ForCurrentProcess()->HasSwitch( 30 CommandLine::ForCurrentProcess()->HasSwitch(
30 switches::kDisableGLErrorLimit)) { 31 switches::kDisableGLErrorLimit)) {
32 std::string prefixed_msg(std::string("[") + GetLogPrefix() + "]" + msg);
31 ++log_message_count_; 33 ++log_message_count_;
32 // LOG this unless logging is turned off as any chromium code that 34 // LOG this unless logging is turned off as any chromium code that
33 // generates these errors probably has a bug. 35 // generates these errors probably has a bug.
34 if (log_synthesized_gl_errors_) { 36 if (log_synthesized_gl_errors_) {
35 ::logging::LogMessage( 37 ::logging::LogMessage(
36 filename, line, ::logging::LOG_ERROR).stream() << msg; 38 filename, line, ::logging::LOG_ERROR).stream() << prefixed_msg;
37 } 39 }
38 if (!msg_callback_.is_null()) { 40 if (!msg_callback_.is_null()) {
39 msg_callback_.Run(0, msg); 41 msg_callback_.Run(0, prefixed_msg);
40 } 42 }
41 } else { 43 } else {
42 if (log_message_count_ == kMaxLogMessages) { 44 if (log_message_count_ == kMaxLogMessages) {
43 ++log_message_count_; 45 ++log_message_count_;
44 LOG(ERROR) 46 LOG(ERROR)
45 << "Too many GL errors, not reporting any more for this context." 47 << "Too many GL errors, not reporting any more for this context."
46 << " use --disable-gl-error-limit to see all errors."; 48 << " use --disable-gl-error-limit to see all errors.";
47 } 49 }
48 } 50 }
49 } 51 }
50 52
51 const std::string& Logger::GetLogPrefix() const { 53 const std::string& Logger::GetLogPrefix() const {
52 const std::string& prefix(debug_marker_manager_->GetMarker()); 54 const std::string& prefix(debug_marker_manager_->GetMarker());
53 return prefix.empty() ? this_in_hex_ : prefix; 55 return prefix.empty() ? this_in_hex_ : prefix;
54 } 56 }
55 57
56 void Logger::SetMsgCallback(const MsgCallback& callback) { 58 void Logger::SetMsgCallback(const MsgCallback& callback) {
57 msg_callback_ = callback; 59 msg_callback_ = callback;
58 } 60 }
59 61
60 } // namespace gles2 62 } // namespace gles2
61 } // namespace gpu 63 } // namespace gpu
62 64
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/error_state.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698