MongoDB C++ Driver mongocxx-4.0.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
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
54class logger {
55 public:
56 virtual ~logger();
57
58 logger(logger&&) = default;
59 logger& operator=(logger&&) = default;
60 logger(const logger&) = default;
61 logger& operator=(const logger&) = default;
62
73 virtual void operator()(log_level level,
75 bsoncxx::v_noabi::stdx::string_view message) noexcept = 0;
76
77 protected:
82};
83
84} // namespace v_noabi
85} // namespace mongocxx
86
87namespace mongocxx {
88
89using ::mongocxx::v_noabi::to_string;
90
91} // namespace mongocxx
92
94
99
100#if defined(MONGOCXX_PRIVATE_DOXYGEN_PREPROCESSOR)
101
102namespace mongocxx {
103
106
107} // namespace mongocxx
108
109#endif // defined(MONGOCXX_PRIVATE_DOXYGEN_PREPROCESSOR)
A polyfill for std::string_view.
Definition string_view.hpp:436
The interface that all user-defined loggers must implement.
Definition logger.hpp:54
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.
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition fwd.hpp:204
Declares utilities related to mongocxx logging.
The mongocxx macro guard postlude header.
The mongocxx 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 message passed to a mongocxx::v_noabi::logger.
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.
bsoncxx::v_noabi::stdx::string_view to_string(v_noabi::log_level level)
mongocxx::v_noabi::to_string(v_noabi::log_level level)
Provides std::string_view-related polyfills for library API usage.