1 /*
2  * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License, version 2.0,
6  * as published by the Free Software Foundation.
7  *
8  * This program is also distributed with certain software (including
9  * but not limited to OpenSSL) that is licensed under separate terms,
10  * as designated in a particular file or component or in included license
11  * documentation.  The authors of MySQL hereby grant you an additional
12  * permission to link the program and your derivative works with the
13  * separately licensed software that they have included with MySQL.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License, version 2.0, for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
23  */
24 
25 #ifndef PLUGIN_X_SRC_XPL_LOG_H_
26 #define PLUGIN_X_SRC_XPL_LOG_H_
27 
28 #if defined(XPLUGIN_LOG_DEBUG) && !defined(XPLUGIN_DISABLE_LOG)
29 #define DEBUG_VAR(YES) YES
30 #else
31 #define DEBUG_VAR(NO)
32 #endif  // defined(XPLUGIN_LOG_DEBUG) && !defined(XPLUGIN_DISABLE_LOG)
33 
34 #ifndef XPLUGIN_DISABLE_LOG
35 
36 #include "plugin/x/generated/mysqlx_version.h"
37 
38 #include <mysql/components/my_service.h>
39 #include <mysql/components/services/log_builtins.h>
40 #include <mysql/plugin.h>
41 #include <mysql/service_my_plugin_log.h>
42 #include <mysqld_error.h>
43 
44 namespace xpl {
45 
46 extern MYSQL_PLUGIN plugin_handle;
47 
48 }  // namespace xpl
49 
50 #define log_error(errcode, ...) \
51   LogPluginErr(ERROR_LEVEL, errcode, ##__VA_ARGS__)
52 
53 #define log_warning(errcode, ...) \
54   LogPluginErr(WARNING_LEVEL, errcode, ##__VA_ARGS__)
55 
56 #define log_info(errcode, ...) \
57   LogPluginErr(INFORMATION_LEVEL, errcode, ##__VA_ARGS__)
58 
59 #define log_system(errcode, ...) LogErr(SYSTEM_LEVEL, errcode, ##__VA_ARGS__)
60 
61 #ifdef XPLUGIN_LOG_DEBUG
62 #define log_debug(...) \
63   LogPluginErrMsg(INFORMATION_LEVEL, ER_XPLUGIN_ERROR_MSG, ##__VA_ARGS__)
64 #else
65 #define log_debug(...) \
66   do {                 \
67   } while (0)
68 #endif
69 
70 #else  // XPLUGIN_DISABLE_LOG
71 
72 #define log_debug(...) \
73   do {                 \
74   } while (0)
75 #define log_info(...) \
76   do {                \
77   } while (0)
78 #define log_warning(...) \
79   do {                   \
80   } while (0)
81 #define log_error(...) \
82   do {                 \
83   } while (0)
84 #define log_system(...) \
85   do {                  \
86   } while (0)
87 
88 #endif  // XPLUGIN_DISABLE_LOG
89 
90 #endif  // PLUGIN_X_SRC_XPL_LOG_H_
91