MySQL 8.4.0
Source Code Documentation
log_sink_buffer.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 @file log_sink_buffer.h
26
27 This file contains
28
29 a) the API for the log-sink that buffers errors logged during start-up
30 so they can be flushed once all configured log-components have become
31 available;
32
33 b) the API for querying and setting the phase the server is in
34 with regard to logging (buffering, normal operation, and so forth);
35
36 c) the API for flushing the buffered information (to force writing
37 out this information in cases of early shutdowns and so on).
38*/
39
40#ifndef LOG_SINK_BUFFER_H
41#define LOG_SINK_BUFFER_H
42
44#include "my_sys.h"
45
46extern mysql_mutex_t THR_LOCK_log_buffered; // let log_builtins init/destroy
47
49 LOG_BUFFER_DISCARD_ONLY, ///< discard all buffered log-events
50 LOG_BUFFER_PROCESS_AND_DISCARD ///< process+discard buffered log-events
51};
52
54 LOG_ERROR_STAGE_BUFFERING, ///< no log-destination yet
55 LOG_ERROR_STAGE_COMPONENTS, ///< external services available
56 LOG_ERROR_STAGE_COMPONENTS_AND_PFS, ///< full logging incl. to pfs
57 LOG_ERROR_STAGE_SHUTTING_DOWN ///< no external components
58};
59
61 log_line ll; ///< log-event we're buffering
62 log_line_buffer *next; ///< chronologically next log-event
63};
64
65/// Set error-logging stage hint (e.g. are loadable services available yet?).
67
68/// What mode is error-logging in (e.g. are loadable services available yet)?
70
71/// Write a log-event to the buffer sink.
72int log_sink_buffer(void *instance [[maybe_unused]], log_line *ll);
73
74/**
75 Release all buffered log-events (discard_error_log_messages()),
76 optionally after running them through the error log stack first
77 (flush_error_log_messages()). Safe to call repeatedly (though
78 subsequent calls will only output anything if further events
79 occurred after the previous flush).
80
81 @param mode LOG_BUFFER_DISCARD_ONLY (to just
82 throw away the buffered events), or
83 LOG_BUFFER_PROCESS_AND_DISCARD to
84 filter/print them first
85*/
87
88/**
89 Prepend a list of log-events to the already buffered events.
90
91 @param[in] head Head of the list to prepend to the main list
92 @param[out] tail Pointer to the `next` pointer in last element to prepend
93*/
95 log_line_buffer **tail);
96
97#endif /* LOG_SINK_BUFFER_H */
int log_sink_buffer(void *instance, log_line *ll)
Write a log-event to the buffer sink.
Definition: log_sink_buffer.cc:179
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:225
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:53
@ LOG_ERROR_STAGE_BUFFERING
no log-destination yet
Definition: log_sink_buffer.h:54
@ LOG_ERROR_STAGE_COMPONENTS
external services available
Definition: log_sink_buffer.h:55
@ LOG_ERROR_STAGE_COMPONENTS_AND_PFS
full logging incl. to pfs
Definition: log_sink_buffer.h:56
@ LOG_ERROR_STAGE_SHUTTING_DOWN
no external components
Definition: log_sink_buffer.h:57
void log_sink_buffer_prepend_list(log_line_buffer *head, log_line_buffer **tail)
Prepend a list of log-events to the already buffered events.
Definition: log_sink_buffer.cc:464
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:255
log_sink_buffer_flush_mode
Definition: log_sink_buffer.h:48
@ LOG_BUFFER_DISCARD_ONLY
discard all buffered log-events
Definition: log_sink_buffer.h:49
@ LOG_BUFFER_PROCESS_AND_DISCARD
process+discard buffered log-events
Definition: log_sink_buffer.h:50
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:220
Common header for many mysys elements.
mode
Definition: file_handle.h:61
log_line ("log event")
Definition: keyring_log_builtins_definition.cc:72
Definition: log_sink_buffer.h:60
log_line ll
log-event we're buffering
Definition: log_sink_buffer.h:61
log_line_buffer * next
chronologically next log-event
Definition: log_sink_buffer.h:62
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:50