MySQL 8.4.0
Source Code Documentation
log_sink_trad.cc File Reference

The built-in log-sink (i.e. More...

#include "log_sink_trad.h"
#include "log_sink_perfschema.h"
#include "my_systime.h"
#include "sql/log.h"

Functions

int log_item_inconsistent (log_item *li)
 Sanity check an item. More...
 
ssize_t parse_trad_field (const char *parse_from, const char **token_end, const char *buf_end)
 Find the end of the current field (' ') More...
 
log_service_error log_sink_trad_parse_log_line (const char *line_start, size_t line_length)
 Parse a single line in the traditional error log. More...
 
int log_sink_trad (void *instance, log_line *ll)
 services: log sinks: basic logging ("classic error-log") Will write timestamp, label, thread-ID, and message to stderr/file. More...
 

Detailed Description

The built-in log-sink (i.e.

the writer for the traditional MySQL error log):

a) writing of an error log event to the traditional error log file b) parsing of a line from the traditional error log file

Function Documentation

◆ log_item_inconsistent()

int log_item_inconsistent ( log_item li)

Sanity check an item.

Certain log sinks have very low requirements with regard to the data they receive; they write keys as strings, and then data according to the item's class (string, integer, or float), formatted to the sink's standards (e.g. JSON, XML, ...). Code that has higher requirements can use this check to see whether the given item is of a known type (whether generic or wellknown), whether the given type and class agree, and whether in case of a well-known type, the given key is correct for that type. If your code generates items that don't pass this check, you should probably go meditate on it.

Parameters
lithe log_item to check
Return values
LOG_ITEM_OKno problems
LOG_ITEM_TYPE_NOT_FOUNDunknown item type
LOG_ITEM_CLASS_MISMATCHitem_class derived from type isn't what's set on the item
LOG_ITEM_KEY_MISMATCHclass not generic, so key should match wellknown
LOG_ITEM_STRING_NULLclass is string, pointer is nullptr
LOG_ITEM_KEY_NULLno key set (this is legal e.g. on aux items of filter rules, but should not occur in a log_line, i.e., log_sinks are within their rights to discard such items)

◆ log_sink_trad()

int log_sink_trad ( void *  instance,
log_line ll 
)

services: log sinks: basic logging ("classic error-log") Will write timestamp, label, thread-ID, and message to stderr/file.

If you should not be able to specify a label, one will be generated for you from the line's priority field.

Parameters
instanceinstance handle
llthe log line to write
Return values
intnumber of added fields, if any

◆ log_sink_trad_parse_log_line()

log_service_error log_sink_trad_parse_log_line ( const char *  line_start,
size_t  line_length 
)

Parse a single line in the traditional error log.

Parameters
line_startpointer to the beginning of the line ('2' of the ISO-date)
line_lengthlength of the line
Return values
LOG_SERVICE_ARGUMENT_TOO_LONGToken too long for its field
LOG_SERVICE_PARSE_ERRORNo more spaces in line, cannot find expected end of token, or input otherwise malformed
LOG_SERVICE_SUCCESSEvent added to ring-buffer

◆ parse_trad_field()

ssize_t parse_trad_field ( const char *  parse_from,
const char **  token_end,
const char *  buf_end 
)

Find the end of the current field (' ')

Parameters
parse_fromstart of the token
token_endwhere to store the address of the delimiter found
buf_endend of the input line
Return values
-1delimiter not found, "parsing" failed
>=0length of token