MySQL  8.0.26
Source Code Documentation
log_builtins_internal.h
Go to the documentation of this file.
1 /* Copyright (c) 2020, 2021, Oracle and/or its affiliates.
2 
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6 
7 This program is also distributed with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have included with MySQL.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, 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  Finding and acquiring a service in the component framework is
38  expensive, and we may use services a log (depending on how many
39  events are logged per second), so we cache the relevant data.
40  This struct describes a given service.
41 */
43  char *name; ///< name of this service
44  size_t name_len; ///< service-name's length
45  my_h_service service; ///< handle (service framework)
46  int opened; ///< currently open instances
47  int requested; ///< requested instances
48  int chistics; ///< multi-open supported, etc.
49 };
50 
51 /**
52  State of a given instance of a service. A service may support being
53  opened several times.
54 */
55 typedef struct _log_service_instance {
56  log_service_cache_entry *sce; ///< the service in question
57  void *instance; ///< instance handle (multi-open)
58  struct _log_service_instance *next; ///< next instance (any service)
60 
62 extern log_service_instance *log_sink_pfs_source; ///< log-reader
63 
64 /**
65  Maximum number of key/value pairs in a log event.
66  May be changed or abolished later.
67 */
68 #define LOG_ITEM_MAX 64
69 
70 /**
71  Iterator over the key/value pairs of a log_line.
72  At present, only one iter may exist per log_line.
73 */
74 typedef struct _log_item_iter {
75  struct _log_line *ll; ///< log_line this is the iter for
76  int index; ///< index of current key/value pair
78 
79 /**
80  log_line ("log event")
81 */
82 typedef struct _log_line {
83  log_item_type_mask seen; ///< bit field flagging item-types contained
84  log_item_iter iter; ///< iterator over key/value pairs
85  log_item output_buffer; ///< buffer a service can return its output in
86  int count; ///< number of key/value pairs ("log items")
87  log_item item[LOG_ITEM_MAX]; ///< log items
89 
90 extern log_filter_ruleset *log_filter_builtin_rules; // what it says on the tin
91 
92 /**
93  Create a log-file name (path + name + extension).
94  The path will be taken from @@log_error.
95  If name + extension are given, they are used.
96  If only an extension is given (argument starts with '.'),
97  the name is taken from @@log_error, and the extension is used.
98  If only a name is given (but no extension), the name and a
99  default extension are used.
100 
101  @param result Buffer to return to created path+name+extension in.
102  Size must be FN_REFLEN.
103  @param name_or_ext if beginning with '.':
104  @@global.log_error, except with this extension
105  otherwise:
106  use this as file name in the same location as
107  @@global.log_error
108 
109  Value may not contain folder separators!
110 
111  @retval LOG_SERVICE_SUCCESS buffer contains a valid result
112  @retval LOG_SERVICE_BUFFER_SIZE_INSUFFICIENT an error occurred
113 */
114 log_service_error make_log_path(char *result, const char *name_or_ext);
115 
116 /**
117  Acquire an exclusive lock on the error logger core.
118 
119  Used e.g. to pause all logging while the previous run's
120  log is read to performance_schema.error_log.
121 */
123 
124 /**
125  Release a lock on the error logger core.
126 */
128 
129 #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:1932
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:1939
log_filter_ruleset * log_filter_builtin_rules
Definition: log_builtins_filter.cc:94
log_service_instance * log_service_instances
anchor
Definition: log_builtins.cc:129
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:2737
#define LOG_ITEM_MAX
Maximum number of key/value pairs in a log event.
Definition: log_builtins_internal.h:68
struct _log_line log_line
log_line ("log event")
log_service_instance * log_sink_pfs_source
log-reader
Definition: log_builtins.cc:135
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:62
int index
index of current key/value pair
Definition: keyring_log_builtins_definition.cc:64
struct _log_line * ll
log_line this is the iter for
Definition: keyring_log_builtins_definition.cc:63
Definition: log_shared.h:195
log_line ("log event")
Definition: keyring_log_builtins_definition.cc:70
int count
number of key/value pairs ("log items")
Definition: keyring_log_builtins_definition.cc:74
log_item_iter iter
iterator over key/value pairs
Definition: keyring_log_builtins_definition.cc:72
log_item_type_mask seen
bit field flagging item-types contained
Definition: keyring_log_builtins_definition.cc:71
log_item item[LOG_ITEM_MAX]
log items
Definition: keyring_log_builtins_definition.cc:75
log_item output_buffer
buffer a service can return its output in
Definition: keyring_log_builtins_definition.cc:73
State of a given instance of a service.
Definition: log_builtins_internal.h:55
struct _log_service_instance * next
next instance (any service)
Definition: log_builtins_internal.h:58
log_service_cache_entry * sce
the service in question
Definition: log_builtins_internal.h:56
void * instance
instance handle (multi-open)
Definition: log_builtins_internal.h:57
Finding and acquiring a service in the component framework is expensive, and we may use services a lo...
Definition: log_builtins_internal.h:42
int chistics
multi-open supported, etc.
Definition: log_builtins_internal.h:48
size_t name_len
service-name's length
Definition: log_builtins_internal.h:44
my_h_service service
handle (service framework)
Definition: log_builtins_internal.h:45
int opened
currently open instances
Definition: log_builtins_internal.h:46
int requested
requested instances
Definition: log_builtins_internal.h:47
char * name
name of this service
Definition: log_builtins_internal.h:43
Definition: result.h:29