MongoDB C++ Driver legacy-1.1.2
Loading...
Searching...
No Matches
log_component_settings.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 "mongo/base/disallow_copying.h"
19#include "mongo/logger/log_component.h"
20#include "mongo/logger/log_severity.h"
21
22namespace mongo {
23namespace logger {
24
31 MONGO_DISALLOW_COPYING(LogComponentSettings);
32
33public:
36
41 bool hasMinimumLogSeverity(LogComponent component) const;
42
48
53
59
67 bool shouldLog(LogComponent component, LogSeverity severity) const;
68
69private:
70 // True if a log severity is explicitly set for a component.
71 // This differentiates between unconfigured components and components that happen to have
72 // the same severity as kDefault.
73 // This is also used to update the severities of unconfigured components when the severity
74 // for kDefault is modified.
75 bool _hasMinimumLoggedSeverity[LogComponent::kNumLogComponents];
76
77 // Log severities for components.
78 // Store numerical values of severities to be cache-line friendly.
79 // Set to kDefault minimum logged severity if _hasMinimumLoggedSeverity[i] is false.
80 char _minimumLoggedSeverity[LogComponent::kNumLogComponents];
81};
82
83} // namespace logger
84} // namespace mongo
Contains log severities for a list of log components.
Definition log_component_settings.h:30
bool hasMinimumLogSeverity(LogComponent component) const
Returns true if a minimum log severity has been set for this component.
void setMinimumLoggedSeverity(LogComponent component, LogSeverity severity)
Sets the minimum log severity for component.
LogSeverity getMinimumLogSeverity(LogComponent component) const
Gets the minimum log severity for component.
void clearMinimumLoggedSeverity(LogComponent component)
Clears the minimum log severity for component.
bool shouldLog(LogComponent component, LogSeverity severity) const
Predicate that answers the question, "Should I, the caller, append to you, the log domain,...
Log components.
Definition log_component.h:32
Representation of the severity / priority of a log message.
Definition log_severity.h:33
Utility functions for parsing numbers from strings.
Definition compare_numbers.h:20