1 /* 2 * This file is part of the zlog Library. 3 * 4 * Copyright (C) 2011 by Hardy Simpson <HardySimpson1984@gmail.com> 5 * 6 * Licensed under the LGPL v2.1, see the file COPYING in base directory. 7 */ 8 9 #ifndef __zc_profile_h 10 #define __zc_profile_h 11 12 #include <stdarg.h> 13 14 #define EMPTY() 15 #define zc_assert(expr, rv) \ 16 if(!(expr)) { \ 17 zc_error(#expr" is null or 0"); \ 18 return rv; \ 19 } 20 21 enum zc_profile_flag { 22 ZC_DEBUG = 0, 23 ZC_WARN = 1, 24 ZC_ERROR = 2 25 }; 26 27 28 #if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L 29 #define zc_debug(...) \ 30 zc_profile_inner(ZC_DEBUG, __FILE__, __LINE__, __VA_ARGS__) 31 #define zc_warn(...) \ 32 zc_profile_inner(ZC_WARN, __FILE__, __LINE__, __VA_ARGS__) 33 #define zc_error(...) \ 34 zc_profile_inner(ZC_ERROR, __FILE__, __LINE__, __VA_ARGS__) 35 #define zc_profile(flag, ...) \ 36 zc_profile_inner(flag, __FILE__, __LINE__, __VA_ARGS__) 37 #elif defined __GNUC__ 38 #define zc_debug(fmt, args...) \ 39 zc_profile_inner(ZC_DEBUG, __FILE__, __LINE__, fmt, ## args) 40 #define zc_warn(fmt, args...) \ 41 zc_profile_inner(ZC_WARN, __FILE__, __LINE__, fmt, ## args) 42 #define zc_error(fmt, args...) \ 43 zc_profile_inner(ZC_ERROR, __FILE__, __LINE__, fmt, ## args) 44 #define zc_profile(flag, fmt, args...) \ 45 zc_profile_inner(flag, __FILE__, __LINE__, fmt, ## args) 46 #endif 47 48 49 int zc_profile_inner(int flag, 50 const char *file, const long line, 51 const char *fmt, ...); 52 53 #endif 54