MySQL 8.0.30
Source Code Documentation
log_sink_buffer.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 @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
43#include "my_sys.h"
44
45extern mysql_mutex_t THR_LOCK_log_buffered; // let log_builtins init/destroy
46
48 LOG_BUFFER_DISCARD_ONLY, ///< discard all buffered log-events
49 LOG_BUFFER_PROCESS_AND_DISCARD ///< process+discard buffered log-events
50};
51
53 LOG_ERROR_STAGE_BUFFERING, ///< no log-destination yet
54 LOG_ERROR_STAGE_COMPONENTS, ///< external services available
55 LOG_ERROR_STAGE_COMPONENTS_AND_PFS, ///< full logging incl. to pfs
56 LOG_ERROR_STAGE_SHUTTING_DOWN ///< no external components
57};
58
59/// Set error-logging stage hint (e.g. are loadable services available yet?).
61
62/// What mode is error-logging in (e.g. are loadable services available yet)?
64
65/// Write a log-event to the buffer sink.
66int log_sink_buffer(void *instance [[maybe_unused]], log_line *ll);
67
68/**
69 Release all buffered log-events (discard_error_log_messages()),
70 optionally after running them through the error log stack first
71 (flush_error_log_messages()). Safe to call repeatedly (though
72 subsequent calls will only output anything if further events
73 occurred after the previous flush).
74
75 @param mode LOG_BUFFER_DISCARD_ONLY (to just
76 throw away the buffered events), or
77 LOG_BUFFER_PROCESS_AND_DISCARD to
78 filter/print them first
79*/
81
82#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:183
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:212
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:52
@ LOG_ERROR_STAGE_BUFFERING
no log-destination yet
Definition: log_sink_buffer.h:53
@ LOG_ERROR_STAGE_COMPONENTS
external services available
Definition: log_sink_buffer.h:54
@ LOG_ERROR_STAGE_COMPONENTS_AND_PFS
full logging incl. to pfs
Definition: log_sink_buffer.h:55
@ LOG_ERROR_STAGE_SHUTTING_DOWN
no external components
Definition: log_sink_buffer.h:56
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:259
log_sink_buffer_flush_mode
Definition: log_sink_buffer.h:47
@ LOG_BUFFER_DISCARD_ONLY
discard all buffered log-events
Definition: log_sink_buffer.h:48
@ LOG_BUFFER_PROCESS_AND_DISCARD
process+discard buffered log-events
Definition: log_sink_buffer.h:49
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:207
Common header for many mysys elements.
mode
Definition: file_handle.h:59
log_line ("log event")
Definition: keyring_log_builtins_definition.cc:71
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:49