MySQL  8.0.27
Source Code Documentation
log_sink_buffer.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  @file log_sink_buffer.h
25 
26  This file contains
27 
28  a) the API for the log-sink that buffers errors logged during start-up
29  so they can be flushed once all configured log-components have become
30  available;
31 
32  b) the API for querying and setting the phase the server is in
33  with regard to logging (buffering, normal operation, and so forth);
34 
35  c) the API for flushing the buffered information (to force writing
36  out this information in cases of early shutdowns and so on).
37 */
38 
39 #ifndef LOG_SINK_BUFFER_H
40 #define LOG_SINK_BUFFER_H
41 
42 #include "log_builtins_internal.h"
43 #include "my_sys.h"
44 
45 extern mysql_mutex_t THR_LOCK_log_buffered; // let log_builtins init/destroy
46 extern int log_buffering_flushworthy;
47 
52 };
53 
55  LOG_ERROR_STAGE_BUFFERING_EARLY, ///< no log-destination yet
56  LOG_ERROR_STAGE_BUFFERING_UNIPLEX, ///< 1 sink, or individual files
57  LOG_ERROR_STAGE_BUFFERING_MULTIPLEX, ///< 2+ sinks writing to stderr
58  LOG_ERROR_STAGE_EXTERNAL_SERVICES_AVAILABLE, ///< external services available
59  LOG_ERROR_STAGE_SHUTTING_DOWN ///< no external components
60 };
61 
62 /// Set error-logging stage hint (e.g. are loadable services available yet?).
64 
65 /// What mode is error-logging in (e.g. are loadable services available yet)?
67 
68 /// Write a log-event to the buffer sink.
69 int log_sink_buffer(void *instance [[maybe_unused]], log_line *ll);
70 
71 /**
72  Release all buffered log-events (discard_error_log_messages()),
73  optionally after running them through the error log stack first
74  (flush_error_log_messages()). Safe to call repeatedly (though
75  subsequent calls will only output anything if further events
76  occurred after the previous flush).
77 
78  @param mode LOG_BUFFER_DISCARD_ONLY (to just
79  throw away the buffered events), or
80  LOG_BUFFER_PROCESS_AND_DISCARD to
81  filter/print them first, or
82  LOG_BUFFER_REPORT_AND_KEEP to print
83  an intermediate report on time-out
84 */
86 
87 #endif /* LOG_SINK_BUFFER_H */
int log_sink_buffer(void *instance[[maybe_unused]], log_line *ll)
Write a log-event to the buffer sink.
Definition: log_sink_buffer.cc:217
enum log_error_stage log_error_stage_get(void)
What mode is error-logging in (e.g. are loadable services available yet)?
Definition: log_builtins.cc:159
mysql_mutex_t THR_LOCK_log_buffered
Make sure only one instance of the buffered "writer" runs at a time.
Definition: log_sink_buffer.cc:76
log_error_stage
Definition: log_sink_buffer.h:54
@ LOG_ERROR_STAGE_BUFFERING_EARLY
no log-destination yet
Definition: log_sink_buffer.h:55
@ LOG_ERROR_STAGE_BUFFERING_UNIPLEX
1 sink, or individual files
Definition: log_sink_buffer.h:56
@ LOG_ERROR_STAGE_BUFFERING_MULTIPLEX
2+ sinks writing to stderr
Definition: log_sink_buffer.h:57
@ LOG_ERROR_STAGE_EXTERNAL_SERVICES_AVAILABLE
external services available
Definition: log_sink_buffer.h:58
@ LOG_ERROR_STAGE_SHUTTING_DOWN
no external components
Definition: log_sink_buffer.h:59
void log_sink_buffer_flush(enum log_sink_buffer_flush_mode mode)
Release all buffered log-events (discard_error_log_messages()), optionally after running them through...
Definition: log_sink_buffer.cc:382
log_sink_buffer_flush_mode
Definition: log_sink_buffer.h:48
@ LOG_BUFFER_DISCARD_ONLY
Definition: log_sink_buffer.h:49
@ LOG_BUFFER_REPORT_AND_KEEP
Definition: log_sink_buffer.h:51
@ LOG_BUFFER_PROCESS_AND_DISCARD
Definition: log_sink_buffer.h:50
int log_buffering_flushworthy
Does buffer contain SYSTEM or ERROR prio messages? Flush early only then!
Definition: log_sink_buffer.cc:111
void log_error_stage_set(enum log_error_stage les)
Set error-logging stage hint (e.g. are loadable services available yet?).
Definition: log_builtins.cc:154
Common header for many mysys elements.
mode
Definition: file_handle.h:59
log_line ("log event")
Definition: keyring_log_builtins_definition.cc:70
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:49