MySQL 8.3.0
Source Code Documentation
log_builtins_internal.h
Go to the documentation of this file.
1/* Copyright (c) 2020, 2023, Oracle and/or its affiliates.
2
3This program is free software; you can redistribute it and/or modify
4it under the terms of the GNU General Public License, version 2.0,
5as published by the Free Software Foundation.
6
7This program is also distributed with certain software (including
8but not limited to OpenSSL) that is licensed under separate terms,
9as designated in a particular file or component or in included license
10documentation. The authors of MySQL hereby grant you an additional
11permission to link the program and your derivative works with the
12separately licensed software that they have included with MySQL.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License, version 2.0, for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
21Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23/*
24 This file contains private definitions for use within the logger,
25 but not by loadable logging components or code that uses the logger
26 but is not part of the logger.
27*/
28
29#ifndef LOG_BUILTINS_DATA_H
30#define LOG_BUILTINS_DATA_H
31
34#include <mysql/components/services/log_shared.h> // public data types
35
36/**
37 When the logger-core was initialized.
38
39 @retval 0 logger-core is not currently available
40 @retval >0 time (micro-seconds since the epoch) the logger became available
41*/
43
44/**
45 MySQL server's default log-processor.
46
47 Apply all components (filters, sinks, ...) in the log stack to a given event.
48
49 @param ll the log-event to process
50
51 @retval true failure
52 @retval false success
53*/
54extern bool log_line_error_stack_run(log_line *ll);
55
56/**
57 Finding and acquiring a service in the component framework is
58 expensive, and we may use services a log (depending on how many
59 events are logged per second), so we cache the relevant data.
60 This struct describes a given service.
61*/
63 char *name; ///< name of this service
64 size_t name_len; ///< service-name's length
65 char *urn; ///< URN of loaded if implicitly loaded, or NULL
66 my_h_service service; ///< handle (service framework)
67 int opened; ///< currently open instances
68 int requested; ///< requested instances
69 int chistics; ///< multi-open supported, etc.
70};
71
72/**
73 State of a given instance of a service. A service may support being
74 opened several times.
75*/
76typedef struct _log_service_instance {
77 log_service_cache_entry *sce; ///< the service in question
78 void *instance; ///< instance handle (multi-open)
79 struct _log_service_instance *next; ///< next instance (any service)
81
83extern log_service_instance *log_sink_pfs_source; ///< log-reader
84
85/**
86 Maximum number of key/value pairs in a log event.
87 May be changed or abolished later.
88*/
89#define LOG_ITEM_MAX 64
90
91/**
92 Iterator over the key/value pairs of a log_line.
93 At present, only one iter may exist per log_line.
94*/
95typedef struct _log_item_iter {
96 struct _log_line *ll; ///< log_line this is the iter for
97 int index; ///< index of current key/value pair
99
100/**
101 log_line ("log event")
102*/
103typedef struct _log_line {
104 log_item_type_mask seen; ///< bit field flagging item-types contained
105 log_item_iter iter; ///< iterator over key/value pairs
106 log_item output_buffer; ///< buffer a service can return its output in
107 int count; ///< number of key/value pairs ("log items")
108 log_item item[LOG_ITEM_MAX]; ///< log items
110
111extern log_filter_ruleset *log_filter_builtin_rules; // what it says on the tin
112
113/**
114 Create a log-file name (path + name + extension).
115 The path will be taken from @@log_error.
116 If name + extension are given, they are used.
117 If only an extension is given (argument starts with '.'),
118 the name is taken from @@log_error, and the extension is used.
119 If only a name is given (but no extension), the name and a
120 default extension are used.
121
122 @param result Buffer to return to created path+name+extension in.
123 Size must be FN_REFLEN.
124 @param name_or_ext if beginning with '.':
125 @@global.log_error, except with this extension
126 otherwise:
127 use this as file name in the same location as
128 @@global.log_error
129
130 Value may not contain folder separators!
131
132 @retval LOG_SERVICE_SUCCESS buffer contains a valid result
133 @retval LOG_SERVICE_BUFFER_SIZE_INSUFFICIENT an error occurred
134*/
135log_service_error make_log_path(char *result, const char *name_or_ext);
136
137/**
138 Acquire an exclusive lock on the error logger core.
139
140 Used e.g. to pause all logging while the previous run's
141 log is read to performance_schema.error_log.
142*/
144
145/**
146 Release a lock on the error logger core.
147*/
149
150#endif /* LOG_BUILTINS_DATA_H */
struct my_h_service_imp * my_h_service
A handle type for acquired Service.
Definition: registry.h:32
void log_builtins_error_stack_wrlock()
Acquire an exclusive lock on the error logger core.
Definition: log_builtins.cc:2148
bool log_line_error_stack_run(log_line *ll)
MySQL server's default log-processor.
Definition: log_builtins.cc:1024
struct _log_item_iter log_item_iter
Iterator over the key/value pairs of a log_line.
void log_builtins_error_stack_unlock()
Release a lock on the error logger core.
Definition: log_builtins.cc:2155
log_filter_ruleset * log_filter_builtin_rules
Definition: log_builtins_filter.cc:95
log_service_instance * log_service_instances
anchor
Definition: log_builtins.cc:195
log_service_error make_log_path(char *result, const char *name_or_ext)
Create a log-file name (path + name + extension).
Definition: log_builtins.cc:2939
#define LOG_ITEM_MAX
Maximum number of key/value pairs in a log event.
Definition: log_builtins_internal.h:89
ulonglong log_builtins_started()
When the logger-core was initialized.
Definition: log_builtins.cc:173
struct _log_line log_line
log_line ("log event")
log_service_instance * log_sink_pfs_source
log-reader
Definition: log_builtins.cc:201
struct _log_service_instance log_service_instance
State of a given instance of a service.
enum enum_log_service_error log_service_error
Error codes.
uint64 log_item_type_mask
a bit mask of log_types.
Definition: log_shared.h:215
unsigned long long int ulonglong
Definition: my_inttypes.h:55
Definition: log_builtins_filter.h:168
Iterator over the key/value pairs of a log_line.
Definition: keyring_log_builtins_definition.cc:63
int index
index of current key/value pair
Definition: keyring_log_builtins_definition.cc:65
struct _log_line * ll
log_line this is the iter for
Definition: keyring_log_builtins_definition.cc:64
Definition: log_shared.h:195
log_line ("log event")
Definition: keyring_log_builtins_definition.cc:71
int count
number of key/value pairs ("log items")
Definition: keyring_log_builtins_definition.cc:75
log_item_iter iter
iterator over key/value pairs
Definition: keyring_log_builtins_definition.cc:73
log_item_type_mask seen
bit field flagging item-types contained
Definition: keyring_log_builtins_definition.cc:72
log_item item[LOG_ITEM_MAX]
log items
Definition: keyring_log_builtins_definition.cc:76
log_item output_buffer
buffer a service can return its output in
Definition: keyring_log_builtins_definition.cc:74
State of a given instance of a service.
Definition: log_builtins_internal.h:76
struct _log_service_instance * next
next instance (any service)
Definition: log_builtins_internal.h:79
log_service_cache_entry * sce
the service in question
Definition: log_builtins_internal.h:77
void * instance
instance handle (multi-open)
Definition: log_builtins_internal.h:78
Finding and acquiring a service in the component framework is expensive, and we may use services a lo...
Definition: log_builtins_internal.h:62
int chistics
multi-open supported, etc.
Definition: log_builtins_internal.h:69
size_t name_len
service-name's length
Definition: log_builtins_internal.h:64
my_h_service service
handle (service framework)
Definition: log_builtins_internal.h:66
int opened
currently open instances
Definition: log_builtins_internal.h:67
char * urn
URN of loaded if implicitly loaded, or NULL.
Definition: log_builtins_internal.h:65
int requested
requested instances
Definition: log_builtins_internal.h:68
char * name
name of this service
Definition: log_builtins_internal.h:63
Definition: result.h:29