blob: 4830a453c10b79fdcccb6e7b68b7782ecce47729 [file] [log] [blame]
Avi Drissman05dfbc822022-09-13 21:25:341// Copyright 2013 The Chromium Authors
kloveless@chromium.org1d82e822013-04-10 21:32:322// 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
Avi Drissman93a273dd2023-01-11 00:38:2714#include "base/functional/callback.h"
Keishi Hattori0e45c022021-11-27 09:25:5215#include "base/memory/raw_ptr.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
kloveless@chromium.org1d82e822013-04-10 21:32:3220namespace gles2 {
21
kloveless@chromium.org1d82e822013-04-10 21:32:3222class DebugMarkerManager;
23
Antoine Labour83a0aed12018-01-10 04:52:3824class GPU_GLES2_EXPORT Logger {
kloveless@chromium.org1d82e822013-04-10 21:32:3225 public:
26 static const int kMaxLogMessages = 256;
27
Peng Huang61eccfe42018-11-15 22:10:1328 using LogMessageCallback = base::RepeatingCallback<void(const std::string&)>;
29
30 Logger(const DebugMarkerManager* debug_marker_manager,
James Darpinian104af6f2018-12-06 03:24:5531 const LogMessageCallback& callback,
32 bool disable_gl_error_limit);
Peter BostrΓΆmdbacdc22021-09-23 22:11:4633
34 Logger(const Logger&) = delete;
35 Logger& operator=(const Logger&) = delete;
36
kloveless@chromium.org1d82e822013-04-10 21:32:3237 ~Logger();
38
39 void LogMessage(const char* filename, int line, const std::string& msg);
40 const std::string& GetLogPrefix() const;
Saifuddin Hitawalae608efe62024-11-14 00:17:4941 bool SuppressPerformanceLogs() const;
kloveless@chromium.org1d82e822013-04-10 21:32:3242
43 // Defaults to true. Set to false for the gpu_unittests as they
44 // are explicitly checking errors are generated and so don't need the numerous
45 // messages. Otherwise, chromium code that generates these errors likely has a
46 // bug.
47 void set_log_synthesized_gl_errors(bool enabled) {
48 log_synthesized_gl_errors_ = enabled;
49 }
50
kloveless@chromium.org1d82e822013-04-10 21:32:3251 private:
52 // Uses the current marker to add information to logs.
Keishi Hattori0e45c022021-11-27 09:25:5253 raw_ptr<const DebugMarkerManager> debug_marker_manager_;
Peng Huang61eccfe42018-11-15 22:10:1354 const LogMessageCallback log_message_callback_;
kloveless@chromium.org1d82e822013-04-10 21:32:3255 std::string this_in_hex_;
56
57 int log_message_count_;
58 bool log_synthesized_gl_errors_;
James Darpinian104af6f2018-12-06 03:24:5559 bool disable_gl_error_limit_;
Saifuddin Hitawalae608efe62024-11-14 00:17:4960 bool suppress_performance_logs_;
kloveless@chromium.org1d82e822013-04-10 21:32:3261};
62
63} // namespace gles2
64} // namespace gpu
65
66#endif // GPU_COMMAND_BUFFER_SERVICE_LOGGER_H_