OceanBase Plugin Development Kit
OceanBase Plugin Development Kit
载入中...
搜索中...
未找到
ob_plugin_log.h
浏览该文件的文档.
1/*
2 * Copyright (c) 2023 OceanBase
3 * OceanBase is licensed under Mulan PubL v2.
4 * You can use this software according to the terms and conditions of the Mulan PubL v2.
5 * You may obtain a copy of Mulan PubL v2 at:
6 * http://license.coscl.org.cn/MulanPubL-2.0
7 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
8 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
9 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
10 * See the Mulan PubL v2 for more details.
11 */
12
13#pragma once
14
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
36
45
50OBP_PUBLIC_API void obp_log_format(int32_t level,
51 const char *filename,
52 int32_t lineno,
53 const char *location_string,
54 int64_t location_string_size,
55 const char *function,
56 const char *format, ...) __attribute__((format(printf, 7, 8)));
57
61#define OBP_LOG(level, fmt, args...) \
62 do { \
63 if (OBP_SUCCESS == obp_log_enabled(level)) { \
64 (void)obp_log_format(level, \
65 __FILE__, \
66 __LINE__, \
67 __FILE__ ":" OBP_STRINGIZE(__LINE__), \
68 sizeof(__FILE__ ":" OBP_STRINGIZE(__LINE__)), \
69 __FUNCTION__, \
70 fmt, \
71 ##args); \
72 } \
73 } while (0)
74
75#define OBP_LOG_TRACE(fmt, args...) OBP_LOG(OBP_LOG_LEVEL_TRACE, fmt, ##args)
76#define OBP_LOG_INFO(fmt, args...) OBP_LOG(OBP_LOG_LEVEL_INFO, fmt, ##args)
77#define OBP_LOG_WARN(fmt, args...) OBP_LOG(OBP_LOG_LEVEL_WARN, fmt, ##args)
78
81#ifdef __cplusplus
82} // extern "C"
83#endif
OBP_PUBLIC_API int obp_log_enabled(int32_t level)
test if we should output the log with specific level
OBP_PUBLIC_API void obp_log_format(int32_t level, const char *filename, int32_t lineno, const char *location_string, int64_t location_string_size, const char *function, const char *format,...) __attribute__((format(printf
logging
ObPluginLogLevel
Log Level
@ OBP_LOG_LEVEL_WARN
@ OBP_LOG_LEVEL_INFO
@ OBP_LOG_LEVEL_TRACE
#define OBP_PUBLIC_API