olp-cpp-sdk  1.22.0
ConsoleAppender.h
1 /*
2  * Copyright (C) 2019-2021 HERE Europe B.V.
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  * SPDX-License-Identifier: Apache-2.0
17  * License-Filename: LICENSE
18  */
19 
20 #pragma once
21 
22 #include <utility>
23 
24 #include <olp/core/CoreApi.h>
25 #include <olp/core/logging/Appender.h>
26 #include <olp/core/logging/MessageFormatter.h>
27 
28 namespace olp {
29 namespace logging {
33 class CORE_API ConsoleAppender : public IAppender {
34  public:
40  inline explicit ConsoleAppender(
42 
48  inline const MessageFormatter& getMessageFormatter() const;
49 
55  inline ConsoleAppender& setMessageFormatter(MessageFormatter formatter);
56 
57  IAppender& append(const LogMessage& message) override;
58 
59  private:
60  MessageFormatter m_formatter;
61 };
62 
64  : m_formatter(std::move(formatter)) {}
65 
67  return m_formatter;
68 }
69 
71  MessageFormatter formatter) {
72  m_formatter = std::move(formatter);
73  return *this;
74 }
75 
76 } // namespace logging
77 } // namespace olp
An appender that prints messages to the console.
Definition: ConsoleAppender.h:33
ConsoleAppender(MessageFormatter formatter=MessageFormatter::createDefault())
Creates a ConsoleAppender instance with a message formatter.
Definition: ConsoleAppender.h:63
ConsoleAppender & setMessageFormatter(MessageFormatter formatter)
Sets the message formatter.
Definition: ConsoleAppender.h:70
IAppender & append(const LogMessage &message) override
Appends the message using char strings.
const MessageFormatter & getMessageFormatter() const
Gets the message formatter.
Definition: ConsoleAppender.h:66
Appends a message to the log.
Definition: Appender.h:32
Specifies how messages are formatted.
Definition: MessageFormatter.h:61
static MessageFormatter createDefault()
Creates the default message formatter.
Rules all the other namespaces.
Definition: AppleSignInProperties.h:24
Contains data used for a log message.
Definition: LogMessage.h:31