MongoDB C++ Driver legacy-1.1.2
Loading...
Searching...
No Matches
log_component.h
1/* Copyright 2014 MongoDB 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
24namespace mongo {
25namespace logger {
26
32class MONGO_CLIENT_API LogComponent {
33public:
34 enum Value {
35 kDefault = 0,
36 kAccessControl,
37 kCommand,
38 kControl,
39 kGeo,
40 kIndex,
41 kNetwork,
42 kQuery,
43 kReplication,
44 kSharding,
45 kStorage,
46 kJournal,
47 kWrite,
48 kNumLogComponents
49 };
50
51 /* implicit */ LogComponent(Value value) : _value(value) {}
52
53 operator Value() const {
54 return _value;
55 }
56
63
68
73 std::string getShortName() const;
74
80 std::string getDottedName() const;
81
88
89private:
90 Value _value;
91};
92
93MONGO_CLIENT_API std::ostream& MONGO_CLIENT_FUNC
94operator<<(std::ostream& os, LogComponent component);
95
96} // namespace logger
97} // namespace mongo
A StringData object wraps a 'const string&' or a 'const char*' without copying its contents.
Definition string_data.h:43
Log components.
Definition log_component.h:32
std::string getDottedName() const
Returns dotted name of log component - short name prefixed by dot-separated names of ancestors.
StringData toStringData() const
Returns short name as a StringData.
std::string getShortName() const
Returns short name of log component.
StringData getNameForLog() const
Returns name suitable for inclusion in formatted log message.
LogComponent parent() const
Returns parent component.
Utility functions for parsing numbers from strings.
Definition compare_numbers.h:20