MySQL  8.0.21
Source Code Documentation
log_sink_syseventlog.cc File Reference
#include <mysql/components/services/log_builtins.h>
#include "log_service_imp.h"
#include "m_string.h"
#include "my_compiler.h"
#include "my_io.h"
#include "my_sys.h"
#include "mysqld_error.h"
#include <mysql/components/component_implementation.h>
#include <mysql/components/service_implementation.h>
#include <mysql/components/services/component_sys_var_service.h>
#include <mysql/plugin.h>
#include "../sql/set_var.h"
#include <syslog.h>

Classes

struct  SYSLOG_FACILITY
 

Macros

#define LOG_DAEMON_NAME   "daemon"
 
#define OPT_FAC   "facility"
 
#define OPT_PID   "include_pid"
 
#define OPT_TAG   "tag"
 
#define LOG_TYPE   "syslog"
 
#define MAX_FAC_LEN   32
 
#define MAX_TAG_LEN   32
 
#define PREFIX   "mysqld"
 
#define MY_NAME   "syseventlog"
 

Functions

 REQUIRES_SERVICE_PLACEHOLDER (component_sys_variable_register)
 
 REQUIRES_SERVICE_PLACEHOLDER (component_sys_variable_unregister)
 
 REQUIRES_SERVICE_PLACEHOLDER (log_builtins)
 
 REQUIRES_SERVICE_PLACEHOLDER (log_builtins_string)
 
 REQUIRES_SERVICE_PLACEHOLDER (log_builtins_syseventlog)
 
 STR_CHECK_ARG (tag) values_tag
 syslog default tag More...
 
 STR_CHECK_ARG (fac) values_fac
 syslog default facility More...
 
 BOOL_CHECK_ARG (pid) values_pid
 syslog default PID state More...
 
static bool log_syslog_find_facility (const char *f, SYSLOG_FACILITY *rsf)
 On being handed a syslog facility name tries to look it up. More...
 
static int log_syslog_close ()
 Close POSIX syslog / Windows EventLog. More...
 
int log_syslog_open ()
 Open POSIX syslog / Windows EventLog. More...
 
static void log_syslog_reopen ()
 Syslog settings have changed; close and re-open. More...
 
void log_syslog_exit (void)
 Stop using syslog / EventLog. More...
 
static int var_check_tag (const char *tag)
 Internal state: Validate new tag to log under. More...
 
static int var_update_tag (const char *tag)
 Internal state: Update tag to log under. More...
 
static int var_check_fac (const char *fac)
 Internal state: Validate facility to log under. More...
 
static int var_update_fac (char *fac)
 Internal state: Update facility to log under May change facility to its canonical representation if needed. More...
 
static int var_update_pid (bool inc_pid)
 Internal state: Toggle inclusion of process ID (pid) More...
 
static int sysvar_check_tag (MYSQL_THD thd, SYS_VAR *self, void *save, struct st_mysql_value *value)
 System-variable: Check proposed value for component variable controlling tag to log under. More...
 
static void sysvar_update_tag (MYSQL_THD thd, SYS_VAR *self, void *var_ptr, const void *save)
 System-variable: Update value of component variable controlling tag to log under Updates internal state as needed. More...
 
static int sysvar_install_tag (void)
 Set up system variable containing the tag to log under (for ident). More...
 
static int sysvar_check_fac (MYSQL_THD thd, SYS_VAR *self, void *save, struct st_mysql_value *value)
 System-variable: Check proposed value for component variable controlling facility to log under. More...
 
static void sysvar_update_fac (MYSQL_THD thd, SYS_VAR *self, void *var_ptr, const void *save)
 System-variable: Update value of component variable controlling facilty to log under Updates internal state as needed. More...
 
static int sysvar_install_fac (void)
 Set up system variable containing the tag to log under (for ident). More...
 
static void sysvar_update_pid (MYSQL_THD thd, SYS_VAR *self, void *var_ptr, const void *save)
 System-variable: Update value of component variable governing inclusion of process ID (pid) Updates internal state as needed. More...
 
static int sysvar_install_pid (void)
 
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_syseventlog, log_service)
 
 END_COMPONENT_PROVIDES ()
 
 REQUIRES_SERVICE (component_sys_variable_register)
 
 REQUIRES_SERVICE (component_sys_variable_unregister)
 
 REQUIRES_SERVICE (log_builtins)
 
 REQUIRES_SERVICE (log_builtins_string)
 
 REQUIRES_SERVICE (log_builtins_syseventlog)
 
 END_COMPONENT_REQUIRES ()
 
 METADATA ("mysql.author", "Oracle Corporation")
 
 METADATA ("mysql.license", "GPL")
 
 METADATA ("log_service_type", "sink")
 
 END_COMPONENT_METADATA ()
 

Variables

static SYSLOG_FACILITY syslog_facility []
 
static bool inited = false
 component initialized More...
 
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_syseventlog_tlog_se = nullptr
 
static int log_syslog_facility = LOG_DAEMON
 facility we're syslogging to More...
 
static bool log_syslog_include_pid = true
 log process ID More...
 
static char * log_syslog_ident = nullptr
 ident we're using (see "tag") More...
 
static bool log_syslog_enabled = false
 logging engaged More...
 
static char * buffer_tag = nullptr
 sysvar containing tag, if any More...
 
static char * buffer_fac = nullptr
 sysvar containing fac, if any More...
 
const mysql_service_log_service_t imp_log_sink_syseventlog_log_service
 
mysql_component_t mysql_component_log_sink_syseventlog
 

Macro Definition Documentation

◆ LOG_DAEMON_NAME

#define LOG_DAEMON_NAME   "daemon"

◆ LOG_TYPE

#define LOG_TYPE   "syslog"

◆ MAX_FAC_LEN

#define MAX_FAC_LEN   32

◆ MAX_TAG_LEN

#define MAX_TAG_LEN   32

◆ MY_NAME

#define MY_NAME   "syseventlog"

◆ OPT_FAC

#define OPT_FAC   "facility"

◆ OPT_PID

#define OPT_PID   "include_pid"

◆ OPT_TAG

#define OPT_TAG   "tag"

◆ PREFIX

#define PREFIX   "mysqld"

Function Documentation

◆ BOOL_CHECK_ARG()

BOOL_CHECK_ARG ( pid  )

syslog default PID state

◆ 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

◆ log_syslog_close()

static int log_syslog_close ( )
static

Close POSIX syslog / Windows EventLog.

Return values
0On Success.
!=0On failure.

◆ log_syslog_exit()

void log_syslog_exit ( void  )

Stop using syslog / EventLog.

Call as late as possible.

◆ log_syslog_find_facility()

static bool log_syslog_find_facility ( const char *  f,
SYSLOG_FACILITY rsf 
)
static

On being handed a syslog facility name tries to look it up.

If successful, fills in a struct with the facility ID and the facility's canonical name.

Parameters
fName of the facility we're trying to look up. Lookup is case-insensitive; leading "log_" is ignored.
[out]rsfA buffer in which to return the ID and canonical name.
Return values
falseNo errors; buffer contains valid result
trueSomething went wrong, no valid result set returned

◆ log_syslog_open()

int log_syslog_open ( )

Open POSIX syslog / Windows EventLog.

Return values
-3log already open, close it before opening again! (log still open)
-2cannot set up new registry entry, continuing with previous value (log still open, but continues to log under previous key)
-1cannot set up new registry entry, no previous value (log not opened)
0success (log opened)

◆ log_syslog_reopen()

static void log_syslog_reopen ( )
static

Syslog settings have changed; close and re-open.

◆ METADATA() [1/3]

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

◆ METADATA() [2/3]

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

◆ METADATA() [3/3]

METADATA ( "log_service_type"  ,
"sink"   
)

◆ PROVIDES_SERVICE()

PROVIDES_SERVICE ( log_sink_syseventlog  ,
log_service   
)

◆ REQUIRES_SERVICE() [1/5]

REQUIRES_SERVICE ( component_sys_variable_register  )

◆ REQUIRES_SERVICE() [2/5]

REQUIRES_SERVICE ( component_sys_variable_unregister  )

◆ REQUIRES_SERVICE() [3/5]

REQUIRES_SERVICE ( log_builtins  )

◆ REQUIRES_SERVICE() [4/5]

REQUIRES_SERVICE ( log_builtins_string  )

◆ REQUIRES_SERVICE() [5/5]

REQUIRES_SERVICE ( log_builtins_syseventlog  )

◆ REQUIRES_SERVICE_PLACEHOLDER() [1/5]

REQUIRES_SERVICE_PLACEHOLDER ( component_sys_variable_register  )

◆ REQUIRES_SERVICE_PLACEHOLDER() [2/5]

REQUIRES_SERVICE_PLACEHOLDER ( component_sys_variable_unregister  )

◆ REQUIRES_SERVICE_PLACEHOLDER() [3/5]

REQUIRES_SERVICE_PLACEHOLDER ( log_builtins  )

◆ REQUIRES_SERVICE_PLACEHOLDER() [4/5]

REQUIRES_SERVICE_PLACEHOLDER ( log_builtins_string  )

◆ REQUIRES_SERVICE_PLACEHOLDER() [5/5]

REQUIRES_SERVICE_PLACEHOLDER ( log_builtins_syseventlog  )

◆ STR_CHECK_ARG() [1/2]

STR_CHECK_ARG ( tag  )

syslog default tag

◆ STR_CHECK_ARG() [2/2]

STR_CHECK_ARG ( fac  )

syslog default facility

◆ sysvar_check_fac()

static int sysvar_check_fac ( MYSQL_THD  thd,
SYS_VAR self,
void *  save,
struct st_mysql_value value 
)
static

System-variable: Check proposed value for component variable controlling facility to log under.

Queries internal state as needed.

Parameters
thdsession
selfthe system variable we're checking
savewhere to save the resulting intermediate (char *) value
valuethe value we're validating
Return values
falsevalue OK, go ahead and update system variable (from "save")
truevalue rejected, do not update variable

◆ sysvar_check_tag()

static int sysvar_check_tag ( MYSQL_THD  thd,
SYS_VAR self,
void *  save,
struct st_mysql_value value 
)
static

System-variable: Check proposed value for component variable controlling tag to log under.

Queries internal state as needed.

Parameters
thdsession
selfthe system variable we're checking
savewhere to save the resulting intermediate (char *) value
valuethe value we're validating
Return values
falsevalue OK, go ahead and update system variable (from "save")
truevalue rejected, do not update variable

◆ sysvar_install_fac()

static int sysvar_install_fac ( void  )
static

Set up system variable containing the tag to log under (for ident).

Return values
0success
-1failure

◆ sysvar_install_pid()

static int sysvar_install_pid ( void  )
static

◆ sysvar_install_tag()

static int sysvar_install_tag ( void  )
static

Set up system variable containing the tag to log under (for ident).

Return values
0success
-1failure

◆ sysvar_update_fac()

static void sysvar_update_fac ( MYSQL_THD  thd,
SYS_VAR self,
void *  var_ptr,
const void *  save 
)
static

System-variable: Update value of component variable controlling facilty to log under Updates internal state as needed.

Parameters
thdsession
selfthe system variable we're changing
var_ptrwhere to save the resulting (char *) value
savepointer to the new value (from check function)

◆ sysvar_update_pid()

static void sysvar_update_pid ( MYSQL_THD  thd,
SYS_VAR self,
void *  var_ptr,
const void *  save 
)
static

System-variable: Update value of component variable governing inclusion of process ID (pid) Updates internal state as needed.

Parameters
thdsession
selfthe system variable we're changing
var_ptrwhere to save the resulting (char *) value
savepointer to the new value (from check function)

◆ sysvar_update_tag()

static void sysvar_update_tag ( MYSQL_THD  thd,
SYS_VAR self,
void *  var_ptr,
const void *  save 
)
static

System-variable: Update value of component variable controlling tag to log under Updates internal state as needed.

Parameters
thdsession
selfthe system variable we're changing
var_ptrwhere to save the resulting (char *) value
savepointer to the new value (from check function)

◆ var_check_fac()

static int var_check_fac ( const char *  fac)
static

Internal state: Validate facility to log under.

Parameters
faca string containing the facility
Return values
0no complaints
-1unknown facility
-2facility name exceeds buffer

◆ var_check_tag()

static int var_check_tag ( const char *  tag)
static

Internal state: Validate new tag to log under.

Parameters
taga string containing the tag
Return values
0no complaints
-1no argument
1invalid argument

◆ var_update_fac()

static int var_update_fac ( char *  fac)
static

Internal state: Update facility to log under May change facility to its canonical representation if needed.

Parameters
facnew facility to log under
Return values
0success

◆ var_update_pid()

static int var_update_pid ( bool  inc_pid)
static

Internal state: Toggle inclusion of process ID (pid)

Parameters
inc_pidinclude PID?
Return values
0success

◆ var_update_tag()

static int var_update_tag ( const char *  tag)
static

Internal state: Update tag to log under.

Parameters
tagnew tag to log under (will be appended to PREFIX)
Return values
0success
-1EINVAL
-2out of memory

Variable Documentation

◆ buffer_fac

char* buffer_fac = nullptr
static

sysvar containing fac, if any

◆ buffer_tag

char* buffer_tag = nullptr
static

sysvar containing tag, if any

◆ imp_log_sink_syseventlog_log_service

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

◆ inited

bool inited = false
static

component initialized

◆ log_bi

accessor built-ins

◆ log_bs

string built-ins

◆ log_se

◆ log_syslog_enabled

bool log_syslog_enabled = false
static

logging engaged

◆ log_syslog_facility

int log_syslog_facility = LOG_DAEMON
static

facility we're syslogging to

◆ log_syslog_ident

char* log_syslog_ident = nullptr
static

ident we're using (see "tag")

◆ log_syslog_include_pid

bool log_syslog_include_pid = true
static

log process ID

◆ mysql_component_log_sink_syseventlog

mysql_component_t mysql_component_log_sink_syseventlog
Initial value:
= { "mysql:log_sink_syseventlog" , __log_sink_syseventlog_provides, __log_sink_syseventlog_requires, __log_sink_syseventlog_metadata,
mysql_service_status_t log_service_exit()
De-initialization method for Component used when unloading the Component.
Definition: log_sink_syseventlog.cc:795
mysql_service_status_t log_service_init()
Initialization entry method for Component used when loading the Component.
Definition: log_sink_syseventlog.cc:833

◆ syslog_facility

SYSLOG_FACILITY syslog_facility[]
static