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