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