1 /* 2 * Copyright 2022 Google LLC 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef skgpu_graphite_Log_DEFINED 9 #define skgpu_graphite_Log_DEFINED 10 11 #include "include/gpu/graphite/LogPriority.h" 12 13 // Ensure SkUserConfig.h is loaded, as clients may define SKGPU_GRAPHITE_LOWEST_ACTIVE_LOG_PRIORITY 14 #include "include/core/SkTypes.h" // IWYU pragma: keep 15 16 #if !defined(SKGPU_GRAPHITE_LOWEST_ACTIVE_LOG_PRIORITY) 17 #ifdef SK_DEBUG 18 #define SKGPU_GRAPHITE_LOWEST_ACTIVE_LOG_PRIORITY skgpu::graphite::LogPriority::kWarning 19 #else 20 #define SKGPU_GRAPHITE_LOWEST_ACTIVE_LOG_PRIORITY skgpu::graphite::LogPriority::kError 21 #endif 22 #endif 23 24 #define SKGPU_LOG(priority, fmt, ...) \ 25 do { \ 26 if (priority <= SKGPU_GRAPHITE_LOWEST_ACTIVE_LOG_PRIORITY) { \ 27 if (priority == skgpu::graphite::LogPriority::kFatal) { \ 28 SK_ABORT("[graphite] " fmt, ##__VA_ARGS__); \ 29 } \ 30 else { \ 31 SkDebugf("[graphite] " fmt "\n", ##__VA_ARGS__); \ 32 } \ 33 } \ 34 } while (0) 35 36 #define SKGPU_LOG_F(fmt, ...) SKGPU_LOG(skgpu::graphite::LogPriority::kFatal, "** ERROR ** " fmt, \ 37 ##__VA_ARGS__) 38 #define SKGPU_LOG_E(fmt, ...) SKGPU_LOG(skgpu::graphite::LogPriority::kError, "** ERROR ** " fmt, \ 39 ##__VA_ARGS__) 40 #define SKGPU_LOG_W(fmt, ...) SKGPU_LOG(skgpu::graphite::LogPriority::kWarning, "WARNING - " fmt, \ 41 ##__VA_ARGS__) 42 #define SKGPU_LOG_D(fmt, ...) SKGPU_LOG(skgpu::graphite::LogPriority::kDebug, fmt, \ 43 ##__VA_ARGS__) 44 45 #endif // skgpu_graphite_Log_DEFINED 46