MongoDB C++ Driver current
Loading...
Searching...
No Matches
logger.hpp
Go to the documentation of this file.
1// Copyright 2009-present 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#pragma once
16
17#include <memory>
18
20
22
24
25namespace mongocxx {
26namespace v_noabi {
27
31enum class log_level {
32 k_error,
34 k_warning,
35 k_message,
36 k_info,
37 k_debug,
38 k_trace,
39};
40
50
57class logger {
58 public:
59 virtual ~logger();
60
61 logger(logger&&) = default;
62 logger& operator=(logger&&) = default;
63 logger(logger const&) = default;
64 logger& operator=(logger const&) = default;
65
76 virtual void operator()(
77 log_level level,
79 bsoncxx::v_noabi::stdx::string_view message) noexcept = 0;
80
81 protected:
86};
87
88} // namespace v_noabi
89} // namespace mongocxx
90
91namespace mongocxx {
92
93using ::mongocxx::v_noabi::to_string;
94
95} // namespace mongocxx
96
98
A polyfill for std::string_view.
Definition string_view.hpp:411
The interface which user-defined loggers must implement.
Definition logger.hpp:57
virtual void operator()(log_level level, bsoncxx::v_noabi::stdx::string_view domain, bsoncxx::v_noabi::stdx::string_view message) noexcept=0
Handles a log message. User defined logger implementations may do whatever they wish when this is cal...
logger()
Default constructor.
Declares utilities related to mongocxx logging.
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
The mongocxx v_noabi macro guard postlude header.
The mongocxx v_noabi macro guard prelude header.
bsoncxx::v_noabi::stdx::string_view to_string(log_level level)
Returns a stringification of the given log level.
log_level
The log level of a log message.
Definition logger.hpp:31
@ k_debug
Log Level Debug.
@ k_warning
Log Level Warning.
@ k_trace
Log Level Trace.
@ k_error
Log Level Error.
@ k_critical
Log Level Critical.
@ k_message
Log Level Message.
The top-level namespace within which all mongocxx library entities are declared.
Provides std::string_view-related polyfills for library API usage.