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