MySQL 8.0.39
Source Code Documentation
|
Modular logger: fluid API. More...
#include <log_builtins.h>
Public Member Functions | |
~LogEvent () | |
Destructor automatically sends the event on. More... | |
LogEvent () | |
"Full customization" constructor. More... | |
void | steal (log_line **save_to) |
LogEvent & | type (enum_log_type val) |
Set log type. More... | |
LogEvent & | errcode (longlong val) |
Append a numeric error code. More... | |
LogEvent & | errsymbol (const char *val) |
Append a (string) error symbol. More... | |
LogEvent & | sqlstate (const char *val) |
Append a (string) SQL state. More... | |
LogEvent & | os_errno (longlong val) |
Append a numeric (operating system, as opposed to MySQL) error number. More... | |
LogEvent & | os_errmsg (const char *val) |
Append a textual (operating system, as opposed to MySQL) error message, vulgo, strerror() More... | |
LogEvent & | source_file (const char *val) |
Which source file was the problem detected in? More... | |
LogEvent & | source_line (longlong val) |
Which line in the source file was the problem detected on? More... | |
LogEvent & | function (const char *val) |
Which function in the source was the problem detected in? More... | |
LogEvent & | subsys (const char *val) |
Which subsystem in the source was the problem detected in? ("Repl"/"InnoDB"/"Server") More... | |
LogEvent & | component (const char *val) |
Which component in the source was the problem detected in? This should be the same string that is given to the component/service framework. More... | |
LogEvent & | user (LEX_CSTRING val) |
What user were we working for at the time of the issue? More... | |
LogEvent & | user (const char *val) |
What user were we working for at the time of the issue? More... | |
LogEvent & | host (LEX_CSTRING val) |
Whose session did the issue appear in? More... | |
LogEvent & | host (const char *val) |
Whose session did the issue appear in? More... | |
LogEvent & | thread_id (longlong val) |
What thread / "connection ID" was the issue detected in? More... | |
LogEvent & | query_id (longlong val) |
What query apparently caused the issue? More... | |
LogEvent & | table_name (const char *val) |
What table were we working on? More... | |
LogEvent & | prio (longlong val) |
Set error message priority. More... | |
LogEvent & | label (const char *val) |
Set a label (usually "warning"/"error"/"information"). More... | |
LogEvent & | verbatim (const char *msg_arg) |
Add a message to the event, verbatim (i.e. More... | |
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 event's message. More... | |
LogEvent & | message (const char *fmt,...) |
Fill in a format string by substituting the % with the given arguments, then add the result as the event's message. More... | |
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 as the event's message. More... | |
LogEvent & | lookup (longlong errcode,...) |
Find an error message by its MySQL error code. More... | |
LogEvent & | lookupv (longlong errcode, va_list args) |
Find an error message by its MySQL error code. More... | |
LogEvent & | lookup_quoted (longlong errcode, const char *tag,...) |
LogEvent & | lookup_quotedv (longlong errcode, const char *tag, va_list vl) |
LogEvent & | int_value (const char *key, longlong val) |
Add a ad hoc integer value with the given key. More... | |
LogEvent & | float_value (const char *key, double val) |
Add a ad hoc (not "well-known") float value with the given key. More... | |
LogEvent & | string_value (const char *key, const char *val, size_t len) |
Add a ad hoc string value with the given key. More... | |
LogEvent & | string_value (const char *key, const char *val) |
Add a ad hoc string value with the given key. More... | |
Private Member Functions | |
bool | set_errcode (longlong errcode) |
Set MySQL error-code if none has been set yet. More... | |
void | set_message (const char *fmt, va_list ap) |
Set the error message. More... | |
void | set_message_by_errcode (longlong errcode, va_list ap) |
Set the error message (by MySQL error code). More... | |
Private Attributes | |
log_line * | ll |
char * | msg |
const char * | msg_tag |
bool | have_msg |
Modular logger: fluid API.
Server-internal. Lets you use safe and expressive syntax, like so:
LogEvent(LOG_TYPE_ERROR).prio(INFORMATION_LEVEL).message("Meow! %d", 4711);
|
inline |
Destructor automatically sends the event on.
It is auto-free()d after processing.
|
inline |
"Full customization" constructor.
Use one of the LogErr() macro where possible; it's there to help you remember the minimum set of particles and their data-types. Be prepared for stern looks from your reviewers if you use this constructor except for external (loadable) services that have no error messages registered with the server, and therefore need to submit them free-form.
|
inline |
Which component in the source was the problem detected in? This should be the same string that is given to the component/service framework.
val | the component. NTBS. |
the | LogEvent, for easy fluent-style chaining. |
Append a numeric error code.
val | the MySQL error code (not operating system errno!). |
the | LogEvent, for easy fluent-style chaining. |
|
inline |
Append a (string) error symbol.
val | error symbol. NTBS. |
the | LogEvent, for easy fluent-style chaining. |
|
inline |
Add a ad hoc (not "well-known") float value with the given key.
key | user-defined key (i.e. not wellknown). NTBS. |
val | value. |
the | LogEvent, for easy fluent-style chaining. |
|
inline |
Which function in the source was the problem detected in?
val | the function's name. NTBS. |
the | LogEvent, for easy fluent-style chaining. |
|
inline |
Whose session did the issue appear in?
val | the host part (of "user@host"). NTBS. |
the | LogEvent, for easy fluent-style chaining. |
|
inline |
Whose session did the issue appear in?
val | the host part (of "user@host"). LEX_CSTRING. |
the | LogEvent, for easy fluent-style chaining. |
Add a ad hoc integer value with the given key.
key | user-defined key (i.e. not wellknown). NTBS. |
val | value. |
the | LogEvent, for easy fluent-style chaining. |
|
inline |
Set a label (usually "warning"/"error"/"information").
Will be derived from prio if not set explicitly. Some log services may ignore custom labels.
val | the (custom) label to set |
the | LogEvent, for easy fluent-style chaining. |
Find an error message by its MySQL error code.
Substitute the % in that message with the given arguments, then add the result as the event's message.
errcode | MySQL error code for the message in question, e.g. ER_STARTUP |
... | varargs to satisfy any % in the message |
the | LogEvent, for easy fluent-style chaining. |
Find an error message by its MySQL error code.
Substitute the % in that message with the given arguments list, then add the result as the event's message.
errcode | MySQL error code for the message in question, e.g. ER_STARTUP |
args | varargs to satisfy any % in the message |
the | LogEvent, for easy fluent-style chaining. |
|
inline |
Fill in a format string by substituting the % with the given arguments, then add the result as the event's message.
If you use this in a context other than an external service that has no messages registered with the server, your reviewers will say unkind things about you. Use registered messages and their error codes wherever possible!
fmt | message (treated as a printf-style format-string, so % substitution will happen) |
... | varargs to satisfy any % in the message |
the | LogEvent, for easy fluent-style chaining. |
|
inline |
Fill in a format string by substituting the % with the given arguments and tag, then add the result as the event's message.
tag | Tag to prefix to message. |
fmt | message (treated as a printf-style format-string, so % substitution will happen) |
... | varargs to satisfy any % in the message |
the | LogEvent, for easy fluent-style chaining. |
|
inline |
Fill in a format string by substituting the % with the given arguments, then add the result as the event's message.
This should be used very sparingly; use registered messages and their error codes wherever possible!
fmt | message (treated as a printf-style format-string, so % substitution will happen) |
ap | valist to satisfy any % in the message |
the | LogEvent, for easy fluent-style chaining. |
|
inline |
Append a textual (operating system, as opposed to MySQL) error message, vulgo, strerror()
val | the error message returned by the operating system. NTBS. |
the | LogEvent, for easy fluent-style chaining. |
Append a numeric (operating system, as opposed to MySQL) error number.
val | the operating system errno. |
the | LogEvent, for easy fluent-style chaining. |
Set error message priority.
Assign one of ERROR_LEVEL, WARNING_LEVEL, INFORMATION_LEVEL. log-writers and other sinks should use this value (rather than that of LOG_ITEM_LOG_EPRIO):
val | The priority for this LogEvent. |
the | LogEvent, for easy fluent-style chaining. |
What query apparently caused the issue?
val | the query_ID of the offending query |
the | LogEvent, for easy fluent-style chaining. |
|
inlineprivate |
Set MySQL error-code if none has been set yet.
errcode | the error code (not operating system errno!) |
true | an error occurred, value not set (OOM?) |
false | value was set without incident, or did not need to be set |
|
inlineprivate |
Set the error message.
fmt | format string. % substitution will be performed. |
ap | va_list of the arguments for % substitution. |
|
inlineprivate |
Set the error message (by MySQL error code).
The actual message will be looked up using this errcode. As the message is a printf-style format string, % substitution will be performed.
errcode | MySQL error code to fetch the message string for |
ap | va_list of the arguments for % substitution. |
|
inline |
Which source file was the problem detected in?
val | the source file's name. NTBS. |
the | LogEvent, for easy fluent-style chaining. |
Which line in the source file was the problem detected on?
val | the line number. |
the | LogEvent, for easy fluent-style chaining. |
|
inline |
Append a (string) SQL state.
val | the SQLstate. NTBS. |
the | LogEvent, for easy fluent-style chaining. |
|
inline |
Save the log-event allocated by LogEvent(). LogEvent() internally represents the log-event in a log_line structure it allocates. steal() saves this pointer to the method's argument. The pointer in the LogEvent() is then cleared to prevent the destructor from freeing the log_line. Freeing allocated memory is now the caller's responsibility: log_line *ll; LogEvent().prio(SYSTEM_LEVEL).message("Hi %s!", user).steal(&ll);
Do some things with the event ...
log_line_item_free_all(ll); log_line_exit(ll); If a message was set, the message buffer pointed to by `msg` becomes part of the log_line and is released on log_line_item_free_all() (or equivalent). If no message was set, the message buffer is released when the LogEvent's destructor is called. Note that verbatim() does NOT copy its argument to the LogEvent's internal allocation `msg`. Hence the life-cycle management of verbatim()'s argument would be up to the developer. When using steal(), using it with one of the set_message() wrappers is generally preferable: LogEvent().message("%s", my_verbatim_string).steal(&ll); @param save_to where to save the pointer to the log-event
|
inline |
Add a ad hoc string value with the given key.
key | user-defined key (i.e. not wellknown). NTBS. |
val | value. NTBS. |
the | LogEvent, for easy fluent-style chaining. |
|
inline |
Add a ad hoc string value with the given key.
key | user-defined key (i.e. not wellknown). NTBS. |
val | value. |
len | length in bytes of the value. |
the | LogEvent, for easy fluent-style chaining. |
|
inline |
Which subsystem in the source was the problem detected in? ("Repl"/"InnoDB"/"Server")
val | the subsystem. NTBS. |
the | LogEvent, for easy fluent-style chaining. |
|
inline |
What table were we working on?
val | the table's name/alias. NTBS. |
the | LogEvent, for easy fluent-style chaining. |
What thread / "connection ID" was the issue detected in?
val | the thread_ID of the session the issue appeared in |
the | LogEvent, for easy fluent-style chaining. |
|
inline |
Set log type.
val | the log type (LOG_TYPE_ERROR) |
the | LogEvent, for easy fluent-style chaining. |
|
inline |
What user were we working for at the time of the issue?
val | the user part (of "user@host"). NTBS. |
the | LogEvent, for easy fluent-style chaining. |
|
inline |
What user were we working for at the time of the issue?
val | the user part (of "user@host"). LEX_CSTRING. |
the | LogEvent, for easy fluent-style chaining. |
|
inline |
Add a message to the event, verbatim (i.e.
with no % substitutions). This is an analog of message("%s", message); it can be used when message may contain user input or a message from another subsystem that could contain % that must not be interpreted as an invitation to do % substitutions.
If you use this in a context other than an external service that has no messages registered with the server, your reviewers will say unkind things about you. Use registered messages and their error codes wherever possible!
Combining verbatim() with steal() is discouraged as it burdens the developer with the life-cycle management of verbatim's argument. This is a result of verbatim() using its argument verbatim, rather than setting it up in the LogEvent's internal allocation msg
using set_message(). Hence, the LogEvent has no copy of the message, which is an optimization for the common, non-steal() case.
msg_arg | the message. % substitution will not happen. |
the | LogEvent, for easy fluent-style chaining. |
|
private |
|
private |
|
private |
|
private |