MongoDB C++ Driver mongocxx-3.11.0
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
23#include <mongocxx/stdx.hpp>
24
26
27namespace mongocxx {
28namespace v_noabi {
29
33enum class log_level {
34 k_error,
36 k_warning,
37 k_message,
38 k_info,
39 k_debug,
40 k_trace,
41};
42
52
56class logger {
57 public:
58 virtual ~logger();
59
60 logger(logger&&) = default;
61 logger& operator=(logger&&) = default;
62 logger(const logger&) = default;
63 logger& operator=(const logger&) = default;
64
75 virtual void operator()(log_level level,
76 stdx::string_view domain,
77 stdx::string_view message) noexcept = 0;
78
79 protected:
84};
85
86} // namespace v_noabi
87} // namespace mongocxx
88
89namespace mongocxx {
90
91using ::mongocxx::v_noabi::to_string;
92
93} // namespace mongocxx
94
96
101
102#if defined(MONGOCXX_PRIVATE_DOXYGEN_PREPROCESSOR)
103
104namespace mongocxx {
105
108
109} // namespace mongocxx
110
111#endif // defined(MONGOCXX_PRIVATE_DOXYGEN_PREPROCESSOR)
A polyfill for std::string_view.
Definition string_view.hpp:503
The interface that all user-defined loggers must implement.
Definition logger.hpp:56
virtual void operator()(log_level level, stdx::string_view domain, 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.
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition fwd.hpp:222
Declares utilities related to mongocxx logging.
The mongocxx macro guard postlude header.
The mongocxx macro guard prelude header.
stdx::string_view to_string(log_level level)
Returns a stringification of the given log level.
log_level
The log level of a message passed to a mongocxx::v_noabi::logger.
Definition logger.hpp:33
@ 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.
bsoncxx::v_noabi::stdx::string_view to_string(v_noabi::log_level level)
mongocxx::v_noabi::to_string(v_noabi::log_level level)
Redeclares bsoncxx::v_noabi::stdx in mongocxx::v_noabi::stdx for internal use.
Provides std::string_view-related polyfills for library API usage.