MongoDB C++ Driver  legacy-1.1.2
log_severity.h
1 /* Copyright 2013 10gen Inc.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #pragma once
17 
18 #include <iosfwd>
19 #include <string>
20 
21 #include "mongo/base/string_data.h"
22 #include "mongo/client/export_macros.h"
23 
24 namespace mongo {
25 namespace logger {
26 
33 class MONGO_CLIENT_API LogSeverity {
34 public:
35  //
36  // Static factory methods for getting LogSeverity objects of the various severity levels.
37  //
38 
39  static inline LogSeverity Severe();
40  static inline LogSeverity Error();
41  static inline LogSeverity Warning();
42  static inline LogSeverity Info();
43  static inline LogSeverity Log(); // === Debug(0)
44  static inline LogSeverity Debug(int debugLevel);
45 
52  static inline LogSeverity cast(int);
53 
54  inline int toInt() const;
55 
59  inline LogSeverity moreSevere() const;
60 
64  inline LogSeverity lessSevere() const;
65 
71  inline std::string toString() const;
72 
79  StringData toStringData() const;
80 
87  char toChar() const;
88 
89  //
90  // Comparison operations.
91  //
92 
94  inline bool operator==(const LogSeverity other) const;
95 
97  inline bool operator!=(const LogSeverity other) const;
98 
100  inline bool operator<(const LogSeverity other) const;
101 
103  inline bool operator<=(const LogSeverity other) const;
104 
106  inline bool operator>(const LogSeverity other) const;
107 
109  inline bool operator>=(const LogSeverity other) const;
110 
111 private:
112  explicit LogSeverity(int severity) : _severity(severity) {}
113 
124  int _severity;
125 };
126 
127 MONGO_CLIENT_API std::ostream& MONGO_CLIENT_FUNC operator<<(std::ostream& os, LogSeverity severity);
128 
129 } // namespace logger
130 } // namespace mongo
131 
132 #include "mongo/logger/log_severity-inl.h"
A StringData object wraps a 'const string&' or a 'const char*' without copying its contents...
Definition: string_data.h:43
Utility functions for parsing numbers from strings.
Definition: compare_numbers.h:20
Representation of the severity / priority of a log message.
Definition: log_severity.h:33