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 3 // found in the LICENSE file. 4 5 // This file contains the Logger class. 6 7 #ifndef GPU_COMMAND_BUFFER_SERVICE_LOGGER_H_ 8 #define GPU_COMMAND_BUFFER_SERVICE_LOGGER_H_ 9 10 #include <string> 11 12 #include "base/callback.h" 13 #include "gpu/gpu_export.h" 14 15 namespace gpu { 16 namespace gles2 { 17 18 typedef base::Callback<void(int32 id, const std::string& msg)> MsgCallback; 19 20 class DebugMarkerManager; 21 22 class GPU_EXPORT Logger { 23 public: 24 static const int kMaxLogMessages = 256; 25 26 explicit Logger(const DebugMarkerManager* debug_marker_manager); 27 ~Logger(); 28 29 void LogMessage(const char* filename, int line, const std::string& msg); 30 const std::string& GetLogPrefix() const; 31 32 // Defaults to true. Set to false for the gpu_unittests as they 33 // are explicitly checking errors are generated and so don't need the numerous 34 // messages. Otherwise, chromium code that generates these errors likely has a 35 // bug. 36 void set_log_synthesized_gl_errors(bool enabled) { 37 log_synthesized_gl_errors_ = enabled; 38 } 39 40 void SetMsgCallback(const MsgCallback& callback); 41 42 private: 43 // Uses the current marker to add information to logs. 44 const DebugMarkerManager* debug_marker_manager_; 45 std::string this_in_hex_; 46 47 int log_message_count_; 48 bool log_synthesized_gl_errors_; 49 50 MsgCallback msg_callback_; 51 DISALLOW_COPY_AND_ASSIGN(Logger); 52 }; 53 54 } // namespace gles2 55 } // namespace gpu 56 57 #endif // GPU_COMMAND_BUFFER_SERVICE_LOGGER_H_ 58 59