1 /* 2 +----------------------------------------------------------------------+ 3 | Copyright (c) 2010 The PHP Group | 4 +----------------------------------------------------------------------+ 5 | This source file is subject to version 3.01 of the PHP license, | 6 | that is bundled with this package in the file LICENSE, and is | 7 | available through the world-wide-web at the following url: | 8 | http://www.php.net/license/3_01.txt. | 9 | If you did not receive a copy of the PHP license and are unable to | 10 | obtain it through the world-wide-web, please send a note to | 11 | license@php.net so we can mail you a copy immediately. | 12 +----------------------------------------------------------------------+ 13 | Authors: Timandes White <timands@gmail.com> | 14 +----------------------------------------------------------------------+ 15 */ 16 17 #include <stdarg.h> 18 #include <zookeeper.h> 19 #include <zookeeper_log.h> /* Symbol LOG_INFO defined in this file conflicts with the symbol defined in syslog.h */ 20 #include "php_zookeeper_log.h" 21 22 #if defined(ZOO_VERSION) || (ZOO_MAJOR_VERSION>=3 && ZOO_MINOR_VERSION>=5) 23 #define PHP_ZK_LOG_ERROR(_zh, ...) LOG_ERROR(LOGCALLBACK(_zh), __VA_ARGS__) 24 #define PHP_ZK_LOG_WARN(_zh, ...) LOG_WARN(LOGCALLBACK(_zh), __VA_ARGS__) 25 #define PHP_ZK_LOG_INFO(_zh, ...) LOG_INFO(LOGCALLBACK(_zh), __VA_ARGS__) 26 #define PHP_ZK_LOG_DEBUG(_zh, ...) LOG_DEBUG(LOGCALLBACK(_zh), __VA_ARGS__) 27 #else 28 #define PHP_ZK_LOG_ERROR(_zh, ...) LOG_ERROR((__VA_ARGS__)) 29 #define PHP_ZK_LOG_WARN(_zh, ...) LOG_WARN((__VA_ARGS__)) 30 #define PHP_ZK_LOG_INFO(_zh, ...) LOG_INFO((__VA_ARGS__)) 31 #define PHP_ZK_LOG_DEBUG(_zh, ...) LOG_DEBUG((__VA_ARGS__)) 32 #endif 33 34 #define PHP_ZK_LOG_FUNC(func, FUNC) \ 35 void php_zk_log_##func(zhandle_t *zh, ...) \ 36 { \ 37 va_list msg; \ 38 va_start(msg, zh); \ 39 PHP_ZK_LOG_##FUNC(zh, va_arg(msg, char*), msg); \ 40 va_end(msg); \ 41 } 42 43 44 PHP_ZK_LOG_FUNC(error, ERROR) 45 PHP_ZK_LOG_FUNC(warn, WARN) 46 PHP_ZK_LOG_FUNC(info, INFO) 47 PHP_ZK_LOG_FUNC(debug, DEBUG) 48