1 // Copyright 2017 The Fuchsia 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 #pragma once 6 7 #include <inttypes.h> 8 #include <stdio.h> 9 10 // TODO(johngro) : replace this with a system which... 11 // 12 // 1) Uses low overhead loging service infrastructure instead of printf. 13 // 2) Uses C/C++ functions (either template parameter packs, or c-style 14 // var-args) instead of preprocessor macros. 15 16 #define VERBOSE_LOGGING 0 17 #define DEBUG_LOGGING (VERBOSE_LOGGING || 0) 18 19 #define LOG_EX(obj, ...) do { \ 20 (obj).PrintDebugPrefix(); \ 21 printf(__VA_ARGS__); \ 22 } while (false) 23 24 #define LOG(...) LOG_EX(*this, __VA_ARGS__) 25 26 #define DEBUG_LOG_EX(obj, ...) do { \ 27 if (DEBUG_LOGGING) { \ 28 (obj).PrintDebugPrefix(); \ 29 printf(__VA_ARGS__); \ 30 } \ 31 } while (false) 32 33 #define DEBUG_LOG(...) DEBUG_LOG_EX(*this, __VA_ARGS__) 34 35 #define VERBOSE_LOG_EX(obj, ...) do { \ 36 if (VERBOSE_LOGGING) { \ 37 (obj).PrintDebugPrefix(); \ 38 printf(__VA_ARGS__); \ 39 } \ 40 } while (false) 41 42 #define VERBOSE_LOG(...) VERBOSE_LOG_EX(*this, __VA_ARGS__) 43