blob: a1b0a93e6abd9314557fdcae36657e4ec8f1256d [file] [log] [blame]
kloveless@chromium.org1d82e822013-04-10 21:32:321// 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
avif15d60a2015-12-21 17:06:3310#include <stdint.h>
11
kloveless@chromium.org1d82e822013-04-10 21:32:3212#include <string>
13
14#include "base/callback.h"
avif15d60a2015-12-21 17:06:3315#include "base/macros.h"
kloveless@chromium.org1d82e822013-04-10 21:32:3216#include "gpu/gpu_export.h"
17
18namespace gpu {
19namespace gles2 {
20
avif15d60a2015-12-21 17:06:3321typedef base::Callback<void(int32_t id, const std::string& msg)> MsgCallback;
kloveless@chromium.org1d82e822013-04-10 21:32:3222
23class DebugMarkerManager;
24
25class 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