MySQL 8.0.40
Source Code Documentation
log_sink_test.cc File Reference

Macros

#define MY_NAME   "log_sink_test"
 
#define LOG_COMPONENT_TAG   MY_NAME
 
#define LOG_SUBSYSTEM_TAG   MY_NAME
 
#define KEY_PRIO_CHANGE   "prio_change"
 
#define VAL_PRIO_CHANGE   "yes"
 
#define KEY_DEL_ITEM   "bark"
 
#define VAL_DEL_ITEM   "delete_by_rule"
 
#define KEY_ADD_ITEM   "far"
 
#define VAL_ADD_ITEM   "added_by_rule"
 
#define KEY_PRS_ITEM   "meow"
 

Functions

 REQUIRES_SERVICE_PLACEHOLDER (registry)
 
 REQUIRES_SERVICE_PLACEHOLDER (log_builtins)
 
 REQUIRES_SERVICE_PLACEHOLDER (log_builtins_string)
 
 REQUIRES_SERVICE_PLACEHOLDER (log_builtins_filter)
 
 REQUIRES_SERVICE_PLACEHOLDER (log_builtins_filter_debug)
 
 REQUIRES_SERVICE_PLACEHOLDER (log_sink_perfschema)
 
static bool rule_delete (log_filter_ruleset *rs, log_item_type t, log_item_key key, log_filter_cond cond, log_filter_verb action)
 delete a rule from the given rule-set More...
 
static void test_add_item_log_me (log_filter_ruleset *rs, const char *label, uint32 orig_count)
 
static void test_if_then_else ()
 Show that flow control actually works. More...
 
static int test_add_item (log_filter_ruleset *rs)
 Show that adding key/value pairs actually works. More...
 
static int test_builtins ()
 Get coverage for some of the built-ins. More...
 
static int test_throttle (log_filter_ruleset *rs)
 Show that the rate-limiter actually works. More...
 
static void banner ()
 Log a message each from the C and the C++ API to the error logger, showing that we can log from external services! More...
 
mysql_service_status_t log_service_exit ()
 De-initialization method for Component used when unloading the Component. More...
 
mysql_service_status_t log_service_init ()
 Initialization entry method for Component used when loading the Component. More...
 
 PROVIDES_SERVICE (log_sink_test, log_service)
 
 END_COMPONENT_PROVIDES ()
 
 REQUIRES_SERVICE (log_builtins)
 
 REQUIRES_SERVICE (log_builtins_string)
 
 REQUIRES_SERVICE (log_builtins_filter)
 
 REQUIRES_SERVICE (log_builtins_filter_debug)
 
 REQUIRES_SERVICE (log_sink_perfschema)
 
 END_COMPONENT_REQUIRES ()
 
 METADATA ("mysql.author", "Oracle Corporation")
 
 METADATA ("mysql.license", "GPL")
 
 METADATA ("log_service_type", "sink")
 
 END_COMPONENT_METADATA ()
 

Variables

const mysql_service_log_builtins_tlog_bi = nullptr
 accessor built-ins More...
 
const mysql_service_log_builtins_string_tlog_bs = nullptr
 string built-ins More...
 
const mysql_service_log_builtins_filter_tlog_bf = nullptr
 
const mysql_service_log_builtins_filter_debug_tlog_fd = nullptr
 
const mysql_service_log_sink_perfschema_tlog_ps = nullptr
 
static bool inited = false
 
static bool failed = false
 
static bool run_tests = true
 
const mysql_service_log_service_t imp_log_sink_test_log_service
 
mysql_component_t mysql_component_log_sink_test
 

Macro Definition Documentation

◆ KEY_ADD_ITEM

#define KEY_ADD_ITEM   "far"

◆ KEY_DEL_ITEM

#define KEY_DEL_ITEM   "bark"

◆ KEY_PRIO_CHANGE

#define KEY_PRIO_CHANGE   "prio_change"

◆ KEY_PRS_ITEM

#define KEY_PRS_ITEM   "meow"

◆ LOG_COMPONENT_TAG

#define LOG_COMPONENT_TAG   MY_NAME

◆ LOG_SUBSYSTEM_TAG

#define LOG_SUBSYSTEM_TAG   MY_NAME

◆ MY_NAME

#define MY_NAME   "log_sink_test"

◆ VAL_ADD_ITEM

#define VAL_ADD_ITEM   "added_by_rule"

◆ VAL_DEL_ITEM

#define VAL_DEL_ITEM   "delete_by_rule"

◆ VAL_PRIO_CHANGE

#define VAL_PRIO_CHANGE   "yes"

Function Documentation

◆ banner()

static void banner ( )
static

Log a message each from the C and the C++ API to the error logger, showing that we can log from external services!

◆ END_COMPONENT_METADATA()

END_COMPONENT_METADATA ( )

◆ END_COMPONENT_PROVIDES()

END_COMPONENT_PROVIDES ( )

◆ END_COMPONENT_REQUIRES()

END_COMPONENT_REQUIRES ( )

◆ log_service_exit()

mysql_service_status_t log_service_exit ( )

De-initialization method for Component used when unloading the Component.

Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ log_service_init()

mysql_service_status_t log_service_init ( )

Initialization entry method for Component used when loading the Component.

Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ METADATA() [1/3]

METADATA ( "log_service_type"  ,
"sink"   
)

◆ METADATA() [2/3]

METADATA ( "mysql.author"  ,
"Oracle Corporation"   
)

◆ METADATA() [3/3]

METADATA ( "mysql.license"  ,
"GPL"   
)

◆ PROVIDES_SERVICE()

PROVIDES_SERVICE ( log_sink_test  ,
log_service   
)

◆ REQUIRES_SERVICE() [1/5]

REQUIRES_SERVICE ( log_builtins  )

◆ REQUIRES_SERVICE() [2/5]

REQUIRES_SERVICE ( log_builtins_filter  )

◆ REQUIRES_SERVICE() [3/5]

REQUIRES_SERVICE ( log_builtins_filter_debug  )

◆ REQUIRES_SERVICE() [4/5]

REQUIRES_SERVICE ( log_builtins_string  )

◆ REQUIRES_SERVICE() [5/5]

REQUIRES_SERVICE ( log_sink_perfschema  )

◆ REQUIRES_SERVICE_PLACEHOLDER() [1/6]

REQUIRES_SERVICE_PLACEHOLDER ( log_builtins  )

◆ REQUIRES_SERVICE_PLACEHOLDER() [2/6]

REQUIRES_SERVICE_PLACEHOLDER ( log_builtins_filter  )

◆ REQUIRES_SERVICE_PLACEHOLDER() [3/6]

REQUIRES_SERVICE_PLACEHOLDER ( log_builtins_filter_debug  )

◆ REQUIRES_SERVICE_PLACEHOLDER() [4/6]

REQUIRES_SERVICE_PLACEHOLDER ( log_builtins_string  )

◆ REQUIRES_SERVICE_PLACEHOLDER() [5/6]

REQUIRES_SERVICE_PLACEHOLDER ( log_sink_perfschema  )

◆ REQUIRES_SERVICE_PLACEHOLDER() [6/6]

REQUIRES_SERVICE_PLACEHOLDER ( registry  )

◆ rule_delete()

static bool rule_delete ( log_filter_ruleset rs,
log_item_type  t,
log_item_key  key,
log_filter_cond  cond,
log_filter_verb  action 
)
static

delete a rule from the given rule-set

Parameters
rsthe rule-set
ttype of match-item
keykey of the match-item if generic (ignored otherwise)
condthe condition-code
actionthe action-verb
Return values
falseno problems, rule deleted
trueerror / no rule deleted

◆ test_add_item()

static int test_add_item ( log_filter_ruleset rs)
static

Show that adding key/value pairs actually works.

Return values
0success
-1could not acquire ruleset (to add throttle)
-2could not initialize new rule
-3could not acquire ruleset (to delete throttle)
-4could not delete all rules

◆ test_add_item_log_me()

static void test_add_item_log_me ( log_filter_ruleset rs,
const char *  label,
uint32  orig_count 
)
static

◆ test_builtins()

static int test_builtins ( )
static

Get coverage for some of the built-ins.

Return values
numberof problems detected

◆ test_if_then_else()

static void test_if_then_else ( )
static

Show that flow control actually works.

This is intended to work in tandem with the log_components_filter.test; the test sets up the filter-rules, and we provided some input to them.

◆ test_throttle()

static int test_throttle ( log_filter_ruleset rs)
static

Show that the rate-limiter actually works.

Return values
0success!
-1could not acquire ruleset (to add throttle)
-2could not initialize new rule
-3could not acquire ruleset (to delete throttle)

Variable Documentation

◆ failed

bool failed = false
static

◆ imp_log_sink_test_log_service

const mysql_service_log_service_t imp_log_sink_test_log_service
Initial value:
= {
nullptr }
static log_service_error open(log_line *ll, void **instance) noexcept
Open a new instance.
Definition: log_filter_dragnet.cc:1568
static int characteristics(void) noexcept
Get characteristics of a log-service.
Definition: log_filter_dragnet.cc:1623
static int run(void *instance, log_line *ll) noexcept
Have the service process one log line.
Definition: log_filter_dragnet.cc:1545
static log_service_error flush(void **instance) noexcept
Flush any buffers.
Definition: log_filter_dragnet.cc:1613
static log_service_error close(void **instance) noexcept
Close and release an instance.
Definition: log_filter_dragnet.cc:1589

◆ inited

bool inited = false
static

◆ log_bf

◆ log_bi

accessor built-ins

◆ log_bs

string built-ins

◆ log_fd

◆ log_ps

◆ mysql_component_log_sink_test

mysql_component_t mysql_component_log_sink_test
Initial value:
= { "mysql:log_sink_test" , __log_sink_test_provides, __log_sink_test_requires, __log_sink_test_metadata,
mysql_service_status_t log_service_exit()
De-initialization method for Component used when unloading the Component.
Definition: log_sink_test.cc:1021
mysql_service_status_t log_service_init()
Initialization entry method for Component used when loading the Component.
Definition: log_sink_test.cc:1045

◆ run_tests

bool run_tests = true
static