MySQL 8.0.30
Source Code Documentation
log_builtins_internal.h
Go to the documentation of this file.
1/* Copyright (c) 2020, 2022, 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 MySQL server's default log-processor.
38
39 Apply all components (filters, sinks, ...) in the log stack to a given event.
40
41 @param ll the log-event to process
42
43 @retval true failure
44 @retval false success
45*/
46extern bool log_line_error_stack_run(log_line *ll);
47
48/**
49 Finding and acquiring a service in the component framework is
50 expensive, and we may use services a log (depending on how many
51 events are logged per second), so we cache the relevant data.
52 This struct describes a given service.
53*/
55 char *name; ///< name of this service
56 size_t name_len; ///< service-name's length
57 char *urn; ///< URN of loaded if implicitly loaded, or NULL
58 my_h_service service; ///< handle (service framework)
59 int opened; ///< currently open instances
60 int requested; ///< requested instances
61 int chistics; ///< multi-open supported, etc.
62};
63
64/**
65 State of a given instance of a service. A service may support being
66 opened several times.
67*/
68typedef struct _log_service_instance {
69 log_service_cache_entry *sce; ///< the service in question
70 void *instance; ///< instance handle (multi-open)
71 struct _log_service_instance *next; ///< next instance (any service)
73
75extern log_service_instance *log_sink_pfs_source; ///< log-reader
76
77/**
78 Maximum number of key/value pairs in a log event.
79 May be changed or abolished later.
80*/
81#define LOG_ITEM_MAX 64
82
83/**
84 Iterator over the key/value pairs of a log_line.
85 At present, only one iter may exist per log_line.
86*/
87typedef struct _log_item_iter {
88 struct _log_line *ll; ///< log_line this is the iter for
89 int index; ///< index of current key/value pair
91
92/**
93 log_line ("log event")
94*/
95typedef struct _log_line {
96 log_item_type_mask seen; ///< bit field flagging item-types contained
97 log_item_iter iter; ///< iterator over key/value pairs
98 log_item output_buffer; ///< buffer a service can return its output in
99 int count; ///< number of key/value pairs ("log items")
100 log_item item[LOG_ITEM_MAX]; ///< log items
102
103extern log_filter_ruleset *log_filter_builtin_rules; // what it says on the tin
104
105/**
106 Create a log-file name (path + name + extension).
107 The path will be taken from @@log_error.
108 If name + extension are given, they are used.
109 If only an extension is given (argument starts with '.'),
110 the name is taken from @@log_error, and the extension is used.
111 If only a name is given (but no extension), the name and a
112 default extension are used.
113
114 @param result Buffer to return to created path+name+extension in.
115 Size must be FN_REFLEN.
116 @param name_or_ext if beginning with '.':
117 @@global.log_error, except with this extension
118 otherwise:
119 use this as file name in the same location as
120 @@global.log_error
121
122 Value may not contain folder separators!
123
124 @retval LOG_SERVICE_SUCCESS buffer contains a valid result
125 @retval LOG_SERVICE_BUFFER_SIZE_INSUFFICIENT an error occurred
126*/
127log_service_error make_log_path(char *result, const char *name_or_ext);
128
129/**
130 Acquire an exclusive lock on the error logger core.
131
132 Used e.g. to pause all logging while the previous run's
133 log is read to performance_schema.error_log.
134*/
136
137/**
138 Release a lock on the error logger core.
139*/
141
142#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:2136
bool log_line_error_stack_run(log_line *ll)
MySQL server's default log-processor.
Definition: log_builtins.cc:1012
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:2143
log_filter_ruleset * log_filter_builtin_rules
Definition: log_builtins_filter.cc:94
log_service_instance * log_service_instances
anchor
Definition: log_builtins.cc:183
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:2926
#define LOG_ITEM_MAX
Maximum number of key/value pairs in a log event.
Definition: log_builtins_internal.h:81
struct _log_line log_line
log_line ("log event")
log_service_instance * log_sink_pfs_source
log-reader
Definition: log_builtins.cc:189
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
Definition: log_builtins_filter.h:149
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:68
struct _log_service_instance * next
next instance (any service)
Definition: log_builtins_internal.h:71
log_service_cache_entry * sce
the service in question
Definition: log_builtins_internal.h:69
void * instance
instance handle (multi-open)
Definition: log_builtins_internal.h:70
Finding and acquiring a service in the component framework is expensive, and we may use services a lo...
Definition: log_builtins_internal.h:54
int chistics
multi-open supported, etc.
Definition: log_builtins_internal.h:61
size_t name_len
service-name's length
Definition: log_builtins_internal.h:56
my_h_service service
handle (service framework)
Definition: log_builtins_internal.h:58
int opened
currently open instances
Definition: log_builtins_internal.h:59
char * urn
URN of loaded if implicitly loaded, or NULL.
Definition: log_builtins_internal.h:57
int requested
requested instances
Definition: log_builtins_internal.h:60
char * name
name of this service
Definition: log_builtins_internal.h:55
Definition: result.h:29