BDE 4.39.x Production Release
Loading...
Searching...
No Matches
ball_recordformatteroptions.h
Go to the documentation of this file.
1/// @file ball_recordformatteroptions.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// ball_recordformatteroptions.h -*-C++-*-
8#ifndef INCLUDED_BALL_RECORDFORMATTEROPTIONS
9#define INCLUDED_BALL_RECORDFORMATTEROPTIONS
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup ball_recordformatteroptions ball_recordformatteroptions
15/// @brief Provides log record formatter option values.
16/// @addtogroup bal
17/// @{
18/// @addtogroup ball
19/// @{
20/// @addtogroup ball_recordformatteroptions
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#ball_recordformatteroptions-purpose"> Purpose</a>
25/// * <a href="#ball_recordformatteroptions-classes"> Classes </a>
26/// * <a href="#ball_recordformatteroptions-description"> Description </a>
27/// * <a href="#ball_recordformatteroptions-usage"> Usage </a>
28/// * <a href="#ball_recordformatteroptions-example-1-configuring-formatter-options"> Example 1: Configuring Formatter Options </a>
29///
30/// # Purpose {#ball_recordformatteroptions-purpose}
31/// Provides log record formatter option values.
32///
33/// # Classes {#ball_recordformatteroptions-classes}
34///
35/// - ball::RecordFormatterOptions: record formatter option values
36///
37/// @see ball_recordformatterregistryutil
38///
39/// # Description {#ball_recordformatteroptions-description}
40/// This component provides a value-semantic attribute class,
41/// `RecordFormatterOptions`, that represents the options that are in addition
42/// to the format string for configuring a log record formatter "plugin".
43///
44/// ## Usage {#ball_recordformatteroptions-usage}
45///
46///
47/// This section illustrates intended use of this component.
48///
49/// ### Example 1: Configuring Formatter Options {#ball_recordformatteroptions-example-1-configuring-formatter-options}
50///
51///
52/// Suppose we are configuring a log record formatter and want to specify
53/// options for how timestamps should be rendered. We can use
54/// `ball::RecordFormatterOptions` to specify these configuration values.
55///
56/// First, we create a `RecordFormatterOptions` object with default settings,
57/// which uses UTC timezone:
58/// @code
59/// ball::RecordFormatterOptions options;
60/// assert(ball::RecordFormatterTimezone::e_UTC == options.timezoneDefault());
61/// @endcode
62/// Then, if we want to configure the formatter to use local time instead, we
63/// can either create the options object with the desired timezone:
64/// @code
65/// ball::RecordFormatterOptions localOptions(
66/// ball::RecordFormatterTimezone::e_LOCAL);
67/// assert(ball::RecordFormatterTimezone::e_LOCAL ==
68/// localOptions.timezoneDefault());
69/// @endcode
70/// Or we can modify an existing options object:
71/// @code
72/// options.setTimezoneDefault(ball::RecordFormatterTimezone::e_LOCAL);
73/// assert(
74/// ball::RecordFormatterTimezone::e_LOCAL == options.timezoneDefault());
75/// @endcode
76/// Finally, we can pass these options to a formatter configuration function
77/// (such as `ball::RecordJsonFormatter::loadJsonSchemeFormatter`) to configure
78/// how timestamps are rendered in the log output.
79/// @}
80/** @} */
81/** @} */
82
83/** @addtogroup bal
84 * @{
85 */
86/** @addtogroup ball
87 * @{
88 */
89/** @addtogroup ball_recordformatteroptions
90 * @{
91 */
92
93#include <balscm_version.h>
94
96
97
98
99namespace ball {
100
101 // ============================
102 // class RecordFormatterOptions
103 // ============================
104
105/// This class provides a value-semantic type for representing options used to
106/// configure log record formatters. These options are supplemental to the
107/// format specification string and affect how certain fields in log records
108/// are rendered. Currently, the only supported option is `timezoneDefault`,
109/// which controls whether timestamps are displayed in UTC or local time.
110///
111/// See @ref ball_recordformatteroptions
113 private:
114 // DATA
115 RecordFormatterTimezone::Enum d_timezoneDefault;
116
117 public:
118 // CREATORS
119
120 /// Create a default `RecordFormatterOptions` object with `e_UTC` as
121 /// its `timezoneDefault` setting.
123
124 /// Create a `RecordFormatterOptions` object with the specified
125 /// `timezoneDefault` setting.
126 explicit RecordFormatterOptions(
128
129 // MANIPULATORS
130
131 /// Set the timezone default value attribute of this object to the
132 /// specified `timezoneDefault`.
134
135 // ACCESSORS
136
137 /// Return a non-modifiable reference to the timezone default attribute of
138 /// this object.
140};
141
142// FREE OPERATORS
143
144/// Return `true` if the specified `lhs` and `rhs` objects have the same
145/// value, and `false` otherwise. Two `RecordFormatterOptions` objects have
146/// the same value if their `timezoneDefault` attributes have the same value.
147bool operator==(const RecordFormatterOptions& lhs,
148 const RecordFormatterOptions& rhs);
149
150/// Return `true` if the specified `lhs` and `rhs` objects do not have the
151/// same value, and `false` otherwise. Two `RecordFormatterOptions` objects
152/// do not have the same value if their `timezoneDefault` attributes do not
153/// have the same value.
154bool operator!=(const RecordFormatterOptions& lhs,
155 const RecordFormatterOptions& rhs);
156
157// ============================================================================
158// INLINE DEFINITIONS
159// ============================================================================
160
161 // ----------------------------
162 // class RecordFormatterOptions
163 // ----------------------------
164
165// CREATORS
166inline
171
172inline
174 RecordFormatterTimezone::Enum timezoneDefault)
175: d_timezoneDefault(timezoneDefault)
176{
177}
178
179inline
181 RecordFormatterTimezone::Enum timezoneDefault)
182{
183 d_timezoneDefault = timezoneDefault;
184}
185
186// ACCESSORS
187inline
190{
191 return d_timezoneDefault;
192}
193
194} // close package namespace
195
196// FREE OPERATORS
197inline
200{
201 return lhs.timezoneDefault() == rhs.timezoneDefault();
202}
203
204inline
207{
208 return !(lhs == rhs);
209}
210
211
212
213#endif
214
215// ----------------------------------------------------------------------------
216// Copyright 2025 Bloomberg Finance L.P.
217//
218// Licensed under the Apache License, Version 2.0 (the "License");
219// you may not use this file except in compliance with the License.
220// You may obtain a copy of the License at
221//
222// http://www.apache.org/licenses/LICENSE-2.0
223//
224// Unless required by applicable law or agreed to in writing, software
225// distributed under the License is distributed on an "AS IS" BASIS,
226// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
227// See the License for the specific language governing permissions and
228// limitations under the License.
229// ----------------------------- END-OF-FILE ----------------------------------
230
231/** @} */
232/** @} */
233/** @} */
Definition ball_recordformatteroptions.h:112
void setTimezoneDefault(RecordFormatterTimezone::Enum timezoneDefault)
Definition ball_recordformatteroptions.h:180
RecordFormatterOptions()
Definition ball_recordformatteroptions.h:167
RecordFormatterTimezone::Enum timezoneDefault() const
Definition ball_recordformatteroptions.h:189
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
Definition ball_administration.h:214
bool operator!=(const Attribute &lhs, const Attribute &rhs)
bool operator==(const Attribute &lhs, const Attribute &rhs)
ALLOCATOR const STRING_VIEW_LIKE_TYPE & rhs
Definition bslstl_string.h:3918
ALLOCATOR & lhs
Definition bslstl_string.h:3917
Definition ball_recordformattertimezone.h:111
Enum
Timezone setting for timestamps in log record formatters.
Definition ball_recordformattertimezone.h:114