31 #ifndef LOG_BUILTINS_H 32 #define LOG_BUILTINS_H 38 #if defined(MYSQL_DYNAMIC_PLUGIN) 45 #if defined(MYSQL_SERVER) && !defined(MYSQL_DYNAMIC_PLUGIN) 380 (log_line * ll, log_item_type_mask
m));
556 (
void *my_errstream, const
char *
buffer,
size_t length));
601 (const
char *a, const
char *b,
size_t len,
602 bool case_insensitive));
617 (
char *to,
size_t n, const
char *fmt, va_list ap))
618 MY_ATTRIBUTE((format(
printf, 3, 0)));
622 MY_ATTRIBUTE((format(printf, 3, 4)));
633 (
void *thd,
uint severity,
uint code,
char *to,
size_t n,
634 const
char *format, ...))
635 MY_ATTRIBUTE((format(printf, 6, 7)));
654 #define log_line_init log_bi->line_init 655 #define log_line_exit log_bi->line_exit 656 #define log_line_item_set_with_key log_bi->line_item_set_with_key 657 #define log_line_item_set log_bi->line_item_set 658 #define log_line_item_types_seen log_bi->line_item_types_seen 659 #define log_line_submit log_bi->line_submit 660 #define log_set_int log_bi->item_set_int 661 #define log_set_float log_bi->item_set_float 662 #define log_set_lexstring log_bi->item_set_lexstring 663 #define log_set_cstring log_bi->item_set_cstring 664 #define log_malloc log_bs->malloc 665 #define log_free log_bs->free 666 #define log_msg log_bs->substitutev 667 #define error_msg_by_errcode log_bi->errmsg_by_errcode 668 #define error_code_by_errsymbol log_bi->errcode_by_errsymbol 673 #define log_malloc(s) my_malloc(0, (s), MYF(0)) 674 #define log_free my_free 675 #define log_msg vsnprintf 676 #define error_msg_by_errcode error_message_for_error_log 677 #define error_code_by_errsymbol mysql_symbol_to_errno 678 #define log_set_int log_item_set_int 679 #define log_set_float log_item_set_float 680 #define log_set_lexstring log_item_set_lexstring 681 #define log_set_cstring log_item_set_cstring 684 #ifndef DISABLE_ERROR_LOGGING 686 #if defined(LOG_COMPONENT_TAG) 688 #define LogErr(severity, ecode, ...) \ 692 .subsys(LOG_SUBSYSTEM_TAG) \ 693 .component(LOG_COMPONENT_TAG) \ 694 .source_line(__LINE__) \ 695 .source_file(MY_BASENAME) \ 696 .function(__FUNCTION__) \ 697 .lookup(ecode, ##__VA_ARGS__) 699 #define LogPluginErr(severity, ecode, ...) \ 703 .subsys(LOG_SUBSYSTEM_TAG) \ 704 .component("plugin:" LOG_COMPONENT_TAG) \ 705 .source_line(__LINE__) \ 706 .source_file(MY_BASENAME) \ 707 .function(__FUNCTION__) \ 708 .lookup_quoted(ecode, "Plugin " LOG_COMPONENT_TAG " reported", \ 711 #define LogPluginErrV(severity, ecode, vl) \ 715 .subsys(LOG_SUBSYSTEM_TAG) \ 716 .component("plugin:" LOG_COMPONENT_TAG) \ 717 .source_line(__LINE__) \ 718 .source_file(MY_BASENAME) \ 719 .function(__FUNCTION__) \ 720 .lookup_quotedv(ecode, "Plugin " LOG_COMPONENT_TAG " reported", vl) 722 #define LogPluginErrMsg(severity, ecode, ...) \ 726 .subsys(LOG_SUBSYSTEM_TAG) \ 727 .component("plugin:" LOG_COMPONENT_TAG) \ 728 .source_line(__LINE__) \ 729 .source_file(MY_BASENAME) \ 730 .function(__FUNCTION__) \ 731 .message_quoted("Plugin " LOG_COMPONENT_TAG " reported", ##__VA_ARGS__) 735 #define LogErr(severity, ecode, ...) \ 739 .subsys(LOG_SUBSYSTEM_TAG) \ 740 .source_line(__LINE__) \ 741 .source_file(MY_BASENAME) \ 742 .function(__FUNCTION__) \ 743 .lookup(ecode, ##__VA_ARGS__) 749 inline void dummy_log_message(longlong severity MY_ATTRIBUTE((unused)),
750 longlong ecode MY_ATTRIBUTE((unused)), ...) {
754 #define LogErr(severity, ecode, ...) \ 755 dummy_log_message(severity, ecode, ##__VA_ARGS__) 757 #define LogPluginErr(severity, ecode, ...) \ 758 dummy_log_message(severity, ecode, ##__VA_ARGS__) 759 #define LogPluginErrV(severity, ecode, ...) \ 760 dummy_log_message(severity, ecode, ##__VA_ARGS__) 761 #define LogPluginErrMsg(severity, ecode, ...) \ 762 dummy_log_message(severity, ecode, ##__VA_ARGS__) 764 #endif // DISABLE_ERROR_LOGGING 788 if (ll ==
nullptr)
return true;
804 MY_ATTRIBUTE((format(printf, 2, 0)));
1145 MY_ATTRIBUTE((format(printf, 2, 0))) {
1165 LogEvent &
message(
const char *fmt, ...) MY_ATTRIBUTE((format(printf, 2, 3)));
1179 MY_ATTRIBUTE((format(printf, 3, 4))) {
1183 va_start(args, fmt);
1203 va_start(args, errcode);
1214 va_start(args, tag);
1295 if ((fmt ==
nullptr) || (*fmt ==
'\0')) fmt =
"invalid error code";
1302 if ((ll !=
nullptr) && (msg !=
nullptr)) {
1304 if (msg_tag !=
nullptr) {
1305 snprintf(buf,
LOG_BUFF_MAX - 1,
"%s: \'%s\'", msg_tag, fmt);
1316 va_start(args, fmt);
1324 #if defined(MYSQL_DYNAMIC_PLUGIN) 1333 inline void deinit_logging_service_for_plugin(
1336 if (*log_bi) (*reg_srv)->release((
my_h_service)(*log_bi));
1337 if (*log_bs) (*reg_srv)->release((
my_h_service)(*log_bs));
1354 inline bool init_logging_service_for_plugin(
1360 if (!(*reg_srv)->acquire(
"log_builtins.mysql_server", &log_srv) &&
1361 !(*reg_srv)->acquire(
"log_builtins_string.mysql_server", &log_str_srv)) {
1362 (*log_bi) =
reinterpret_cast<SERVICE_TYPE(log_builtins) *
>(log_srv);
1364 reinterpret_cast<SERVICE_TYPE(log_builtins_string) *
>(log_str_srv);
1366 deinit_logging_service_for_plugin(reg_srv, log_bi, log_bs);
1372 #elif defined(EXTRA_CODE_FOR_UNIT_TESTING) 1384 inline bool init_logging_service_for_plugin(
1385 SERVICE_TYPE(registry) * *reg_srv MY_ATTRIBUTE((unused)),
1386 SERVICE_TYPE(log_builtins) * *log_bi MY_ATTRIBUTE((unused)),
1387 SERVICE_TYPE(log_builtins_string) * *log_bs MY_ATTRIBUTE((unused)))
1400 inline void deinit_logging_service_for_plugin(
1401 SERVICE_TYPE(registry) * *reg_srv MY_ATTRIBUTE((unused)),
1402 SERVICE_TYPE(log_builtins) * *log_bi MY_ATTRIBUTE((unused)),
1403 SERVICE_TYPE(log_builtins_string) * *log_bs MY_ATTRIBUTE((unused))) {}
1405 #endif // MYSQL_DYNAMIC_PLUGIN 1407 #endif // __cplusplus #define log_set_lexstring
Definition: log_builtins.h:662
connection ID
Definition: log_shared.h:141
LogEvent & string_value(const char *key, const char *val)
Add a ad hoc string value with the given key.
Definition: log_builtins.h:1283
Definition: log_shared.h:176
LogEvent & lookup_quoted(longlong errcode, const char *tag,...)
Definition: log_builtins.h:1210
#define free(A)
Definition: fts0ast.h:42
LogEvent & host(const char *val)
Whose session did the issue appear in?
Definition: log_builtins.h:1033
log called from component ...
Definition: log_shared.h:138
responsible user on host ...
Definition: log_shared.h:140
Specifies macros to define Components.
const string name("\ame\)
offending thread owned by ...
Definition: log_shared.h:139
char buffer[STRING_BUFFER]
Definition: test_sql_9_sessions.cc:57
LogEvent & int_value(const char *key, longlong val)
Add a ad hoc integer value with the given key.
Definition: log_builtins.h:1236
enum_log_type
log_type – which log to send data to check vs enum_log_table_type and LOG_FILE/LOG_TABLE/LOG_NONE ...
Definition: log_shared.h:68
bool set_errcode(longlong errcode)
Set MySQL error-code if none has been set yet.
Definition: log_builtins.h:787
int mysql_plugin_registry_release(const mysql_service_registry_t *reg)
Releases a registry service reference.
Definition: plugin_registry_service.cc:74
#define log_set_cstring
Definition: log_builtins.h:663
#define log_free
Definition: log_builtins.h:665
Definition: log_shared.h:182
unsigned int uint32
Definition: my_inttypes.h:56
~LogEvent()
Destructor automatically sends the event on.
Definition: log_builtins.h:822
const char * str
Definition: mysql_lex_string.h:40
enum enum_log_item_type log_item_type
item_type – what to log
struct module_t * m
Definition: dbug_analyze.cc:469
#define SERVICE_TYPE(name)
Declaration of the registry plugin service.
LogEvent & verbatim(const char *msg_arg)
Add a message to the event, verbatim (i.e.
Definition: log_builtins.h:1127
integer not otherwise specified
Definition: log_shared.h:152
Definition: mysql_lex_string.h:39
#define malloc(A)
Definition: fts0ast.h:41
LogEvent & message_quoted(const char *tag, const char *fmt,...)
Fill in a format string by substituting the % with the given arguments and tag, then add the result a...
Definition: log_builtins.h:1178
label, unless auto-derived
Definition: log_shared.h:145
uint64 log_item_type_mask
a bit mask of log_types.
Definition: log_shared.h:212
LogEvent & type(enum_log_type val)
Set log type.
Definition: log_builtins.h:857
log_line ("log event")
Definition: log_builtins_imp.h:63
SQL state.
Definition: log_shared.h:131
#define log_line_exit
Definition: log_builtins.h:655
#define close(s)
Definition: win32.h:103
void write(W *w, const T &t, const char *key, size_t key_sz)
Definition: sdi_impl.h:333
log called from file ...
Definition: log_shared.h:134
const char * msg_tag
Definition: log_builtins.h:777
structure to define some default "config_option" option settings
Definition: innodb_config.h:180
mysql error code (symbolic)
Definition: log_shared.h:130
LogEvent & lookup_quotedv(longlong errcode, const char *tag, va_list vl)
Definition: log_builtins.h:1221
#define DECLARE_METHOD(retval, name, args)
LogEvent & errcode(longlong val)
Append a numeric error code.
Definition: log_builtins.h:869
char * msg
Definition: log_builtins.h:776
LogEvent & thread_id(longlong val)
What thread / "connection ID" was the issue detected in?
Definition: log_builtins.h:1045
#define log_line_init
Definition: log_builtins.h:654
#define log_line_item_set_with_key
Definition: log_builtins.h:656
LogEvent & source_line(longlong val)
Which line in the source file was the problem detected on?
Definition: log_builtins.h:942
LogEvent()
"Full customization" constructor.
Definition: log_builtins.h:838
void set_message(const char *fmt, va_list ap)
Set the error message.
Definition: log_builtins.h:1301
size_t length
Definition: mysql_lex_string.h:41
#define LOG_BUFF_MAX
advisory.
Definition: log_shared.h:221
LogEvent & message(const char *fmt,...)
Fill in a format string by substituting the % with the given arguments, then add the result as the ev...
Definition: log_builtins.h:1314
Header for compiler-dependent features.
unsigned int len
Definition: dbug_analyze.cc:216
LogEvent & lookup(longlong errcode,...)
Find an error message by its MySQL error code.
Definition: log_builtins.h:1201
float not otherwise specified
Definition: log_shared.h:151
unsigned int uint
Definition: uca-dump.cc:29
LogEvent & host(LEX_CSTRING val)
Whose session did the issue appear in?
Definition: log_builtins.h:1020
LogEvent & query_id(longlong val)
What query apparently caused the issue?
Definition: log_builtins.h:1057
long long int longlong
Definition: my_inttypes.h:70
log called from function ...
Definition: log_shared.h:136
t
Definition: dbug_analyze.cc:147
mysql error code (numeric)
Definition: log_shared.h:129
const mysql_service_registry_t * mysql_plugin_registry_acquire()
Returns a new reference to the "registry" service.
Definition: plugin_registry_service.cc:46
char msg[1024]
Definition: test_sql_9_sessions.cc:282
log called from line ...
Definition: log_shared.h:135
void set_message_by_errcode(longlong errcode, va_list ap)
Set the error message (by MySQL error code).
Definition: log_builtins.h:1292
#define BEGIN_SERVICE_DEFINITION(name)
#define log_line_item_types_seen
Definition: log_builtins.h:658
LogEvent & os_errmsg(const char *val)
Append a textual (operating system, as opposed to MySQL) error message, vulgo, strerror() ...
Definition: log_builtins.h:918
LogEvent & sqlstate(const char *val)
Append a (string) SQL state.
Definition: log_builtins.h:893
#define log_set_int
Definition: log_builtins.h:660
static const char * key
Definition: suite_stubs.c:14
const mysql_service_log_builtins_string_t * log_bs
string built-ins
Definition: log_filter_dragnet.cc:129
LogEvent & prio(longlong val)
Set error message priority.
Definition: log_builtins.h:1092
LogEvent & errsymbol(const char *val)
Append a (string) error symbol.
Definition: log_builtins.h:881
LogEvent & float_value(const char *key, double val)
Add a ad hoc (not "well-known") float value with the given key.
Definition: log_builtins.h:1251
lex string not otherwise specified
Definition: log_shared.h:153
query ID
Definition: log_shared.h:142
#define log_msg
Definition: log_builtins.h:666
LogEvent & user(const char *val)
What user were we working for at the time of the issue?
Definition: log_builtins.h:1008
Definition: log_shared.h:192
LogEvent & label(const char *val)
Set a label (usually "warning"/"error"/"information").
Definition: log_builtins.h:1106
OS strerror()
Definition: log_shared.h:133
OS errno.
Definition: log_shared.h:132
loglevel
Definition: my_loglevel.h:32
Iterator over the key/value pairs of a log_line.
Definition: log_builtins_imp.h:55
LogEvent & string_value(const char *key, const char *val, size_t len)
Add a ad hoc string value with the given key.
Definition: log_builtins.h:1267
LogEvent & os_errno(longlong val)
Append a numeric (operating system, as opposed to MySQL) error number.
Definition: log_builtins.h:905
void * alloc(size_t size)
Definition: sql_class.h:301
static const mysql_service_registry_t * reg_srv
Initialize parameters required for error logging.
Definition: test_plugin.cc:61
the message, format string
Definition: log_shared.h:147
#define log_set_float
Definition: log_builtins.h:661
table name
Definition: log_shared.h:143
LogEvent & source_file(const char *val)
Which source file was the problem detected in?
Definition: log_builtins.h:930
LogEvent & user(LEX_CSTRING val)
What user were we working for at the time of the issue?
Definition: log_builtins.h:995
#define END_SERVICE_DEFINITION(name)
Error logging, slow query logging, general query logging: If it's server-internal, and it's logging, it's here.
struct my_h_service_imp * my_h_service
A handle type for acquired Service.
Definition: registry.h:32
log_line * ll
Definition: log_builtins.h:775
LogEvent & component(const char *val)
Which component in the source was the problem detected in? This should be the same string that is giv...
Definition: log_builtins.h:982
#define error_msg_by_errcode
Definition: log_builtins.h:667
LogEvent & subsys(const char *val)
Which subsystem in the source was the problem detected in? ("Repl"/"InnoDB"/"Server") ...
Definition: log_builtins.h:967
Specifies macros to define Service Implementations.
error log, etc.
Definition: log_shared.h:128
Modular logger: fluid API.
Definition: log_builtins.h:773
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:75
log priority (error, warn, ...)
Definition: log_shared.h:144
#define log_line_submit
Definition: log_builtins.h:659
enum enum_log_item_class log_item_class
static int compare(size_t a, size_t b)
Function to compare two size_t integers for their relative order.
Definition: rpl_utility.cc:101
LogEvent & table_name(const char *val)
What table were we working on?
Definition: log_builtins.h:1069
log called from subsystem ...
Definition: log_shared.h:137
const mysql_service_log_builtins_t * log_bi
accessor built-ins
Definition: log_filter_dragnet.cc:128
static int log_type
Definition: mi_log.cc:45
LogEvent & messagev(const char *fmt, va_list ap)
Fill in a format string by substituting the % with the given arguments, then add the result as the ev...
Definition: log_builtins.h:1144
#define log_line_item_set
Definition: log_builtins.h:657
#define log_malloc
Definition: log_builtins.h:664