Microsoft Information Protection SDK - C++ 1.17
API Reference Documentation for C++
Loading...
Searching...
No Matches
logger_delegate.h
Go to the documentation of this file.
1/*
2 *
3 * Copyright (c) Microsoft Corporation.
4 * All rights reserved.
5 *
6 * This code is licensed under the MIT License.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files(the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions :
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 *
26 */
35#ifndef API_MIP_LOGGER_DELEGATE_H_
36#define API_MIP_LOGGER_DELEGATE_H_
37
38#include <memory>
39#include <string>
40
42#include "mip/mip_namespace.h"
43
44MIP_NAMESPACE_BEGIN
45
50public:
56 virtual void Init(const std::string& storagePath) = 0;
60 virtual void Flush() = 0;
70 virtual void WriteToLog (
71 const LogLevel level,
72 const std::string& message,
73 const std::string& function,
74 const std::string& file,
75 const int32_t line) = 0;
76
87 virtual void WriteToLogWithContext (
88 const LogLevel level,
89 const std::string& message,
90 const std::string& function,
91 const std::string& file,
92 const int32_t line,
93 const std::shared_ptr<void>& /*context*/) {
94 WriteToLog(level, message, function, file, line);
95 }
96
102 virtual void WriteToLogWithLogMessage(const LogMessageData& logMessage) {
104 logMessage.GetLevel(),
105 logMessage.GetLogMessage(),
106 logMessage.GetFunction(),
107 logMessage.GetFile(),
108 logMessage.GetLine(),
109 logMessage.GetContext());
110 }
111
113 virtual ~LoggerDelegate() {}
114protected:
115 LoggerDelegate() {}
117};
118
119MIP_NAMESPACE_END
120#endif // API_MIP_LOGGER_DELEGATE_H_
121
A class that stores log messages.
Definition log_message_data.h:58
const std::shared_ptr< void > & GetContext() const
The logger context for the log statement.
Definition log_message_data.h:107
const std::string & GetLogMessage() const
The message for the log statement.
Definition log_message_data.h:87
const std::string & GetFile() const
The file name for the log statement.
Definition log_message_data.h:97
const std::string & GetFunction() const
The function name for the log statement.
Definition log_message_data.h:92
LogLevel GetLevel() const
The log level for the log statement.
Definition log_message_data.h:82
int32_t GetLine() const
The line number for the log statement.
Definition log_message_data.h:102
A class that defines the interface to the MIP SDK logger.
Definition logger_delegate.h:49
virtual void WriteToLogWithContext(const LogLevel level, const std::string &message, const std::string &function, const std::string &file, const int32_t line, const std::shared_ptr< void > &)
Write a log statement to log file with a context. Override this function to handle the context.
Definition logger_delegate.h:87
virtual void Flush()=0
Flush the logger.
virtual void WriteToLog(const LogLevel level, const std::string &message, const std::string &function, const std::string &file, const int32_t line)=0
Write a log statement to log file.
virtual void WriteToLogWithLogMessage(const LogMessageData &logMessage)
Write a log statement to a log.
Definition logger_delegate.h:102
virtual void Init(const std::string &storagePath)=0
Initialize the logger.
Contains the LogMessageData class for logging.
LogLevel
Different log levels used across the MIP SDK.
Definition log_message_data.h:48
MIP namespace macros.