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 namespace skgpu::graphite { 12 enum class Priority : int { 13 kFatal = 0, 14 kError = 1, 15 kWarning = 2, 16 kDebug = 3, 17 }; 18 }; // namespace skgpu::graphite 19 20 #if !defined(SKGPU_LOWEST_ACTIVE_PRIORITY) 21 #ifdef SK_DEBUG 22 #define SKGPU_LOWEST_ACTIVE_PRIORITY skgpu::graphite::Priority::kWarning 23 #else 24 #define SKGPU_LOWEST_ACTIVE_PRIORITY skgpu::graphite::Priority::kError 25 #endif 26 #endif 27 #define SKGPU_LOG(priority, fmt, ...) \ 28 do { \ 29 if (priority <= SKGPU_LOWEST_ACTIVE_PRIORITY) { \ 30 SkDebugf("[graphite] " fmt "\n", ##__VA_ARGS__); \ 31 if (priority == skgpu::graphite::Priority::kFatal) { \ 32 SK_ABORT("Fatal log call"); \ 33 } \ 34 } \ 35 } while (0) 36 #define SKGPU_LOG_F(fmt, ...) SKGPU_LOG(skgpu::graphite::Priority::kFatal, "** ERROR ** " fmt, \ 37 ##__VA_ARGS__) 38 #define SKGPU_LOG_E(fmt, ...) SKGPU_LOG(skgpu::graphite::Priority::kError, "** ERROR ** " fmt, \ 39 ##__VA_ARGS__) 40 #define SKGPU_LOG_W(fmt, ...) SKGPU_LOG(skgpu::graphite::Priority::kWarning, "WARNING - " fmt, \ 41 ##__VA_ARGS__) 42 #define SKGPU_LOG_D(fmt, ...) SKGPU_LOG(skgpu::graphite::Priority::kDebug, fmt, \ 43 ##__VA_ARGS__) 44 45 #endif // skgpu_graphite_Log_DEFINED 46