blob: af907b97c1532260c50b856c9713803c37d251fe [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"
Antoine Labour83a0aed12018-01-10 04:52:3816#include "gpu/gpu_gles2_export.h"
kloveless@chromium.org1d82e822013-04-10 21:32:3217
18namespace gpu {
Jonathan Backer1d807a42018-01-08 20:45:5419
20class DecoderClient;
21
kloveless@chromium.org1d82e822013-04-10 21:32:3222namespace gles2 {
23
kloveless@chromium.org1d82e822013-04-10 21:32:3224class DebugMarkerManager;
25
Antoine Labour83a0aed12018-01-10 04:52:3826class GPU_GLES2_EXPORT Logger {
kloveless@chromium.org1d82e822013-04-10 21:32:3227 public:
28 static const int kMaxLogMessages = 256;
29
Jonathan Backer1d807a42018-01-08 20:45:5430 Logger(const DebugMarkerManager* debug_marker_manager, DecoderClient* client);
kloveless@chromium.org1d82e822013-04-10 21:32:3231 ~Logger();
32
33 void LogMessage(const char* filename, int line, const std::string& msg);
34 const std::string& GetLogPrefix() const;
35
36 // Defaults to true. Set to false for the gpu_unittests as they
37 // are explicitly checking errors are generated and so don't need the numerous
38 // messages. Otherwise, chromium code that generates these errors likely has a
39 // bug.
40 void set_log_synthesized_gl_errors(bool enabled) {
41 log_synthesized_gl_errors_ = enabled;
42 }
43
kloveless@chromium.org1d82e822013-04-10 21:32:3244 private:
45 // Uses the current marker to add information to logs.
46 const DebugMarkerManager* debug_marker_manager_;
Jonathan Backer1d807a42018-01-08 20:45:5447 DecoderClient* client_;
kloveless@chromium.org1d82e822013-04-10 21:32:3248 std::string this_in_hex_;
49
50 int log_message_count_;
51 bool log_synthesized_gl_errors_;
52
kloveless@chromium.org1d82e822013-04-10 21:32:3253 DISALLOW_COPY_AND_ASSIGN(Logger);
54};
55
56} // namespace gles2
57} // namespace gpu
58
59#endif // GPU_COMMAND_BUFFER_SERVICE_LOGGER_H_