MongoDB C++ Driver mongocxx-3.10.1
Loading...
Searching...
No Matches
logger.hpp
1// Copyright 2015 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
19#include <mongocxx/logger-fwd.hpp>
20
21#include <bsoncxx/stdx/string_view.hpp>
22#include <mongocxx/stdx.hpp>
23
24#include <mongocxx/config/prelude.hpp>
25
26namespace mongocxx {
27namespace v_noabi {
28
32enum class log_level {
33 k_error,
34 k_critical,
35 k_warning,
36 k_message,
37 k_info,
38 k_debug,
39 k_trace,
40};
41
50MONGOCXX_API stdx::string_view MONGOCXX_CALL to_string(log_level level);
51
55class logger {
56 public:
57 virtual ~logger();
58
69 virtual void operator()(log_level level,
70 stdx::string_view domain,
71 stdx::string_view message) noexcept = 0;
72
73 protected:
78};
79
80} // namespace v_noabi
81} // namespace mongocxx
82
83namespace mongocxx {
84
85using ::mongocxx::v_noabi::to_string;
86
87} // namespace mongocxx
88
89#include <mongocxx/config/postlude.hpp>
The interface that all user-defined loggers must implement.
Definition logger.hpp:55
virtual void operator()(log_level level, stdx::string_view domain, stdx::string_view message) noexcept=0
Handles a log message.
logger()
Default constructor.
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:32
The top-level namespace for mongocxx library entities.
Definition bulk_write-fwd.hpp:19