BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bsls_logseverity.h
Go to the documentation of this file.
1/// @file bsls_logseverity.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bsls_logseverity.h -*-C++-*-
8#ifndef INCLUDED_BSLS_LOGSEVERITY
9#define INCLUDED_BSLS_LOGSEVERITY
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bsls_logseverity bsls_logseverity
15/// @brief Enumerate a set of logging severity levels.
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bsls
19/// @{
20/// @addtogroup bsls_logseverity
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bsls_logseverity-purpose"> Purpose</a>
25/// * <a href="#bsls_logseverity-classes"> Classes </a>
26/// * <a href="#bsls_logseverity-description"> Description </a>
27/// * <a href="#bsls_logseverity-enumerators"> Enumerators </a>
28/// * <a href="#bsls_logseverity-usage"> Usage </a>
29/// * <a href="#bsls_logseverity-example-1-basic-syntax"> Example 1: Basic Syntax </a>
30///
31/// # Purpose {#bsls_logseverity-purpose}
32/// Enumerate a set of logging severity levels.
33///
34/// # Classes {#bsls_logseverity-classes}
35///
36/// - bsls::LogSeverity: namespace for enumerating logging severity levels
37///
38/// @see bsls_log
39///
40/// # Description {#bsls_logseverity-description}
41/// This component provides a namespace for the `enum` type
42/// `bsls::LogSeverity::Enum`, which enumerates a set of severity levels used
43/// for logging with `bsls_log`.
44///
45/// ## Enumerators {#bsls_logseverity-enumerators}
46///
47///
48/// @code
49/// Name Description
50/// ----------- -------------------------------------------------------------
51/// e_FATAL A severity appropriate for log messages accompanying a fatal
52/// event (i.e., one that will cause a *crash*).
53///
54/// e_ERROR A severity appropriate for log messages accompanying an
55/// unexpected error (i.e., one that will cause incorrect
56/// behavior).
57///
58/// e_WARN A severity appropriate for log messages accompanying an
59/// event that may indicate a problem.
60///
61/// e_INFO A severity appropriate for log messages providing informative
62/// status about the running process.
63///
64/// e_DEBUG A severity appropriate for log messages providing information
65/// useful for debugging.
66///
67/// e_TRACE A severity appropriate for log messages providing detailed
68/// trace information.
69/// @endcode
70///
71/// ## Usage {#bsls_logseverity-usage}
72///
73///
74/// This section illustrates intended use of this component.
75///
76/// ### Example 1: Basic Syntax {#bsls_logseverity-example-1-basic-syntax}
77///
78///
79/// The following snippets of code provide a simple illustration of using
80/// `bsls::LogSeverity`.
81///
82/// First, we create a variable `value` of type `bsls::LogSeverity::Enum`
83/// and initialize it with the enumerator value
84/// `bsls::LogSeverity::e_DEBUG`:
85/// @code
86/// bsls::LogSeverity::Enum value = bsls::LogSeverity::e_DEBUG;
87/// @endcode
88/// Now, we store the address of its ASCII representation in a pointer variable,
89/// `asciiValue`, of type `const char *`:
90/// @code
91/// const char *asciiValue = bsls::LogSeverity::toAscii(value);
92/// @endcode
93/// Finally, we verify the value of `asciiValue`:
94/// @code
95/// assert(0 == strcmp(asciiValue, "DEBUG"));
96/// @endcode
97/// @}
98/** @} */
99/** @} */
100
101/** @addtogroup bsl
102 * @{
103 */
104/** @addtogroup bsls
105 * @{
106 */
107/** @addtogroup bsls_logseverity
108 * @{
109 */
110
111
112namespace bsls {
113
114 // ==================
115 // struct LogSeverity
116 // ==================
117
118/// This `struct` provides a namespace for enumerating the set of logging
119/// severity levels used in the `bsls` logging framework (see `bsls_log`).
120/// See `Enum` in the TYPES sub-section for details.
122
123 public:
124 // TYPES
125 enum Enum {
126 // Enumeration of logging severity levels.
127
128 e_FATAL = 0, // a condition that will (likely) cause a *crash*
129 e_ERROR = 1, // a condition that *will* cause incorrect behavior
130 e_WARN = 2, // a *potentially* problematic condition
131 e_INFO = 3, // data about the running process
132 e_DEBUG = 4, // information useful while debugging
133 e_TRACE = 5 // execution trace data
134 };
135
136 public:
137 /// Return the non-modifiable string representation corresponding to the
138 /// specified enumeration `value`, if it exists, and a unique (error)
139 /// string otherwise. The string representation of `value` matches its
140 /// corresponding enumerator name with the "e_" prefix elided. For
141 /// example:
142 /// @code
143 /// bsl::cout << LogSeverity::toAscii(LogSeverity::e_DEBUG);
144 /// @endcode
145 /// will print the following on standard output:
146 /// @code
147 /// DEBUG
148 /// @endcode
149 /// Note that specifying a `value` that does not match any of the
150 /// enumerators will result in a string representation that is distinct
151 /// from any of those corresponding to the enumerators, but is otherwise
152 /// unspecified.
153 static const char *toAscii(LogSeverity::Enum value);
154};
155
156} // close package namespace
157
158
159#endif
160
161// ----------------------------------------------------------------------------
162// Copyright 2016 Bloomberg Finance L.P.
163//
164// Licensed under the Apache License, Version 2.0 (the "License");
165// you may not use this file except in compliance with the License.
166// You may obtain a copy of the License at
167//
168// http://www.apache.org/licenses/LICENSE-2.0
169//
170// Unless required by applicable law or agreed to in writing, software
171// distributed under the License is distributed on an "AS IS" BASIS,
172// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
173// See the License for the specific language governing permissions and
174// limitations under the License.
175// ----------------------------- END-OF-FILE ----------------------------------
176
177/** @} */
178/** @} */
179/** @} */
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bdlt_iso8601util.h:691
Definition bsls_logseverity.h:121
Enum
Definition bsls_logseverity.h:125
static const char * toAscii(LogSeverity::Enum value)