X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Flogging%2Flog.h;h=25136ab7d99ce67114bf94e6834a9d9aabce686c;hb=1eca514c6bc89f9359c3a1e2214e71d55d4700c1;hp=20754c1f1d422b5c3ac67043f9ede4a7e3c23a75;hpb=4fa90f321f51af8f5bfc48eee1435e2f41d853b3;p=babeltrace.git diff --git a/src/logging/log.h b/src/logging/log.h index 20754c1f..25136ab7 100644 --- a/src/logging/log.h +++ b/src/logging/log.h @@ -1,7 +1,10 @@ /* + * SPDX-License-Identifier: MIT + * + * Copyright (c) 2016 wonder-mice + * * This is zf_log.h, modified with Babeltrace prefixes. * See . - * See logging/LICENSE in the Babeltrace source tree. */ #pragma once @@ -15,6 +18,11 @@ #include #include +/* Access private __BT_LOGGING_LEVEL_* macros. */ +#define __BT_IN_BABELTRACE_H +#include +#undef __BT_IN_BABELTRACE_H + #include "common/macros.h" #include "common/assert.h" @@ -55,13 +63,13 @@ * should be empty or very small. Choosing a right log level is as important as * providing short and self descriptive log message. */ -#define BT_LOG_TRACE BT_LOGGING_LEVEL_TRACE -#define BT_LOG_DEBUG BT_LOGGING_LEVEL_DEBUG -#define BT_LOG_INFO BT_LOGGING_LEVEL_INFO -#define BT_LOG_WARNING BT_LOGGING_LEVEL_WARNING -#define BT_LOG_ERROR BT_LOGGING_LEVEL_ERROR -#define BT_LOG_FATAL BT_LOGGING_LEVEL_FATAL -#define BT_LOG_NONE BT_LOGGING_LEVEL_NONE +#define BT_LOG_TRACE __BT_LOGGING_LEVEL_TRACE +#define BT_LOG_DEBUG __BT_LOGGING_LEVEL_DEBUG +#define BT_LOG_INFO __BT_LOGGING_LEVEL_INFO +#define BT_LOG_WARNING __BT_LOGGING_LEVEL_WARNING +#define BT_LOG_ERROR __BT_LOGGING_LEVEL_ERROR +#define BT_LOG_FATAL __BT_LOGGING_LEVEL_FATAL +#define BT_LOG_NONE __BT_LOGGING_LEVEL_NONE /* "Current" log level is a compile time check and has no runtime overhead. Log * level that is below current log level it said to be "disabled". @@ -232,39 +240,8 @@ #define BT_LOG_SRCLOC_SHORT 1 #define BT_LOG_SRCLOC_LONG 2 -/* Source location format is configured per compilation module (.c/.cpp/.m - * file) by defining BT_LOG_DEF_SRCLOC or BT_LOG_SRCLOC. BT_LOG_SRCLOC has - * higer priority and when defined overrides value provided by - * BT_LOG_DEF_SRCLOC. - * - * Common practice is to define default format with BT_LOG_DEF_SRCLOC in - * build script (e.g. Makefile, CMakeLists.txt, gyp, etc.) for the entire - * project or target: - * - * CC_ARGS := -DBT_LOG_DEF_SRCLOC=BT_LOG_SRCLOC_LONG - * - * And when necessary to override it with BT_LOG_SRCLOC in .c/.cpp/.m files - * before including bt_log.h: - * - * #define BT_LOG_SRCLOC BT_LOG_SRCLOC_NONE - * #include "logging.h" - * - * If both BT_LOG_DEF_SRCLOC and BT_LOG_SRCLOC are undefined, then - * BT_LOG_SRCLOC_NONE will be used for release builds (BT_DEBUG_MODE is - * NOT defined) and BT_LOG_SRCLOC_LONG otherwise (BT_DEBUG_MODE is - * defined). - */ -#if defined(BT_LOG_SRCLOC) - #define _BT_LOG_SRCLOC BT_LOG_SRCLOC -#elif defined(BT_LOG_DEF_SRCLOC) - #define _BT_LOG_SRCLOC BT_LOG_DEF_SRCLOC -#else - #ifdef BT_DEBUG_MODE - #define _BT_LOG_SRCLOC BT_LOG_SRCLOC_LONG - #else - #define _BT_LOG_SRCLOC BT_LOG_SRCLOC_NONE - #endif -#endif +#define _BT_LOG_SRCLOC BT_LOG_SRCLOC_LONG + #if BT_LOG_SRCLOC_LONG == _BT_LOG_SRCLOC #define _BT_LOG_SRCLOC_FUNCTION _BT_LOG_FUNCTION #else @@ -893,6 +870,7 @@ static _BT_LOG_INLINE void _bt_log_unused(const int dummy, ...) {(void)dummy;} BT_LOG_WRITE_MEM(log, BT_LOG_TRACE, _BT_LOG_TAG, d, d_sz, __VA_ARGS__) #else #define BT_LOGT(...) _BT_LOG_UNUSED(__VA_ARGS__) + #define BT_LOGT_ERRNO(...) _BT_LOG_UNUSED(__VA_ARGS__) #define BT_LOGT_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__) #define BT_LOGT_MEM(...) _BT_LOG_UNUSED(__VA_ARGS__) #define BT_LOGT_MEM_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__) @@ -911,6 +889,7 @@ static _BT_LOG_INLINE void _bt_log_unused(const int dummy, ...) {(void)dummy;} BT_LOG_WRITE_MEM_AUX(log, BT_LOG_DEBUG, _BT_LOG_TAG, d, d_sz, __VA_ARGS__) #else #define BT_LOGD(...) _BT_LOG_UNUSED(__VA_ARGS__) + #define BT_LOGD_ERRNO(...) _BT_LOG_UNUSED(__VA_ARGS__) #define BT_LOGD_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__) #define BT_LOGD_MEM(...) _BT_LOG_UNUSED(__VA_ARGS__) #define BT_LOGD_MEM_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__) @@ -929,6 +908,7 @@ static _BT_LOG_INLINE void _bt_log_unused(const int dummy, ...) {(void)dummy;} BT_LOG_WRITE_MEM_AUX(log, BT_LOG_INFO, _BT_LOG_TAG, d, d_sz, __VA_ARGS__) #else #define BT_LOGI(...) _BT_LOG_UNUSED(__VA_ARGS__) + #define BT_LOGI_ERRNO(...) _BT_LOG_UNUSED(__VA_ARGS__) #define BT_LOGI_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__) #define BT_LOGI_MEM(...) _BT_LOG_UNUSED(__VA_ARGS__) #define BT_LOGI_MEM_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__) @@ -947,6 +927,7 @@ static _BT_LOG_INLINE void _bt_log_unused(const int dummy, ...) {(void)dummy;} BT_LOG_WRITE_MEM_AUX(log, BT_LOG_WARNING, _BT_LOG_TAG, d, d_sz, __VA_ARGS__) #else #define BT_LOGW(...) _BT_LOG_UNUSED(__VA_ARGS__) + #define BT_LOGW_ERRNO(...) _BT_LOG_UNUSED(__VA_ARGS__) #define BT_LOGW_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__) #define BT_LOGW_MEM(...) _BT_LOG_UNUSED(__VA_ARGS__) #define BT_LOGW_MEM_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__) @@ -965,6 +946,7 @@ static _BT_LOG_INLINE void _bt_log_unused(const int dummy, ...) {(void)dummy;} BT_LOG_WRITE_MEM_AUX(log, BT_LOG_ERROR, _BT_LOG_TAG, d, d_sz, __VA_ARGS__) #else #define BT_LOGE(...) _BT_LOG_UNUSED(__VA_ARGS__) + #define BT_LOGE_ERRNO(...) _BT_LOG_UNUSED(__VA_ARGS__) #define BT_LOGE_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__) #define BT_LOGE_MEM(...) _BT_LOG_UNUSED(__VA_ARGS__) #define BT_LOGE_MEM_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__) @@ -983,6 +965,7 @@ static _BT_LOG_INLINE void _bt_log_unused(const int dummy, ...) {(void)dummy;} BT_LOG_WRITE_MEM_AUX(log, BT_LOG_FATAL, _BT_LOG_TAG, d, d_sz, __VA_ARGS__) #else #define BT_LOGF(...) _BT_LOG_UNUSED(__VA_ARGS__) + #define BT_LOGF_ERRNO(...) _BT_LOG_UNUSED(__VA_ARGS__) #define BT_LOGF_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__) #define BT_LOGF_MEM(...) _BT_LOG_UNUSED(__VA_ARGS__) #define BT_LOGF_MEM_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__)