Hazelcast C++ Client
Hazelcast C++ Client Library
logger_config.h
1 /*
2  * Copyright (c) 2008-2021, Hazelcast, Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 
18 #include <stdexcept>
19 #include <string>
20 
21 #include "hazelcast/logger.h"
22 #include "hazelcast/util/export.h"
23 #include "hazelcast/util/Preconditions.h"
24 
25 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
26 #pragma warning(push)
27 #pragma warning(disable: 4251) //for dll export
28 #endif
29 
30 namespace hazelcast {
31  namespace client {
32  namespace config {
33  class HAZELCAST_API logger_config {
34  public:
40  logger::level level() {
41  return level_;
42  }
43 
49  logger_config &level(logger::level level) {
50  level_ = level;
51  return *this;
52  }
53 
54 
58  logger::handler_type handler() {
59  return handler_;
60  }
61 
71  logger_config &handler(logger::handler_type handler) {
72  util::Preconditions::check_true(handler, "log handler may not be empty");
73  handler_ = std::move(handler);
74  return *this;
75  }
76 
77  private:
78  logger::level level_{ logger::level::info };
79  logger::handler_type handler_{ logger::default_handler };
80  };
81  }
82  }
83 }
84 
85 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
86 #pragma warning(pop)
87 #endif
88 
89 
logger::level level()
Minimum level of log messages to be printed.
Definition: logger_config.h:40
logger_config & level(logger::level level)
Set the minimum severity level of log messages to be printed.
Definition: logger_config.h:49
logger_config & handler(logger::handler_type handler)
Set a log handler function to be invoked on each log message.
Definition: logger_config.h:71