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_Log_DEFINED 9 #define skgpu_Log_DEFINED 10 11 namespace skgpu { 12 enum class Priority : int { 13 kError = 0, 14 kWarning = 1, 15 kDebug = 2, 16 }; 17 }; // namespace skgpu 18 19 #if !defined(SKGPU_LOWEST_ACTIVE_PRIORITY) 20 #ifdef SK_DEBUG 21 #define SKGPU_LOWEST_ACTIVE_PRIORITY Priority::kWarning 22 #else 23 #define SKGPU_LOWEST_ACTIVE_PRIORITY Priority::kError 24 #endif 25 #endif 26 #define SKGPU_LOG(priority, fmt, ...) \ 27 do { \ 28 if (priority <= SKGPU_LOWEST_ACTIVE_PRIORITY) { \ 29 SkDebugf("[graphite] " fmt "\n", ##__VA_ARGS__); \ 30 } \ 31 } while (0) 32 #define SKGPU_LOG_E(fmt, ...) SKGPU_LOG(skgpu::Priority::kError, "** ERROR ** " fmt, ##__VA_ARGS__) 33 #define SKGPU_LOG_W(fmt, ...) SKGPU_LOG(skgpu::Priority::kWarning, "WARNING - " fmt, ##__VA_ARGS__) 34 #define SKGPU_LOG_D(fmt, ...) SKGPU_LOG(skgpu::Priority::kDebug, fmt, ##__VA_ARGS__) 35 36 #endif // skgpu_Log_DEFINED 37