Microsoft Information Protection (MIP) SDK for C++: Reference 1.15
Doxygen-generated documentation for MIP SDK written in C++
Loading...
Searching...
No Matches
log_message_data.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 */
27/**
28 * @brief Contains the LogMessageData class for logging
29 *
30 * @file log_message_data.h
31 */
32
33
34#ifndef API_MIP_LOG_MESSAGE_DATA_H_
35#define API_MIP_LOG_MESSAGE_DATA_H_
36
37#include <chrono>
38#include <memory>
39#include <string>
40#include <thread>
41
42#include "mip/mip_namespace.h"
43
44MIP_NAMESPACE_BEGIN
45/**
46 * @brief Different log levels used across the MIP SDK.
47 */
48enum class LogLevel : unsigned int {
49 Trace = 0, /* Log statement is of type Trace */
50 Info = 1, /* Log statement is of type Info */
51 Warning = 2, /* Log statement is of type Warning */
52 Error = 3, /* Log statement is of type Error */
53};
54
55/**
56 * @brief A class that stores log messages
57 */
59public:
61 const LogLevel level,
62 const std::string& message,
63 const std::string& function,
64 const std::string& file,
65 int32_t line,
66 const std::shared_ptr<void>& context,
67 std::chrono::time_point<std::chrono::system_clock> messageTime,
68 std::thread::id messageThreadId)
69 : mLevel(level),
70 mLogMessage(message),
71 mFunction(function),
72 mFile(file),
73 mLine(line),
74 mContext(context),
75 mMessageTime(messageTime),
76 mMessageThreadId(messageThreadId) {
77 }
78
79 /**
80 * @brief The log level for the log statement
81 */
82 LogLevel GetLevel() const { return mLevel; }
83
84 /**
85 * @brief The message for the log statement
86 */
87 const std::string& GetLogMessage() const { return mLogMessage; }
88
89 /**
90 * @brief The function name for the log statement
91 */
92 const std::string& GetFunction() const { return mFunction; }
93
94 /**
95 * @brief The file name for the log statement
96 */
97 const std::string& GetFile() const { return mFile; }
98
99 /**
100 * @brief The line number for the log statement
101 */
102 int32_t GetLine() const { return mLine; }
103
104 /**
105 * @brief The logger context for the log statement
106 */
107 const std::shared_ptr<void>& GetContext() const { return mContext; }
108
109 /**
110 * @brief The message time of the log statement
111 */
112 std::chrono::time_point<std::chrono::system_clock> GetMessageTime() const { return mMessageTime; }
113
114 /**
115 * @brief The thread id of the log statement
116 */
117 std::thread::id GetMessageThreadId() const { return mMessageThreadId; }
118
119private:
120 LogLevel mLevel;
121 std::string mLogMessage;
122 std::string mFunction;
123 std::string mFile;
124 int32_t mLine;
125 std::shared_ptr<void> mContext;
126 std::chrono::time_point<std::chrono::system_clock> mMessageTime;
127 std::thread::id mMessageThreadId;
128};
129
130MIP_NAMESPACE_END
131#endif // API_MIP_LOG_MESSAGE_DATA_H_
132
Base class for all errors that will be reported (thrown or returned) from MIP SDK.
Definition error.h:114
A class that stores log messages.
const std::shared_ptr< void > & GetContext() const
The logger context for the log statement.
LogMessageData(const LogLevel level, const std::string &message, const std::string &function, const std::string &file, int32_t line, const std::shared_ptr< void > &context, std::chrono::time_point< std::chrono::system_clock > messageTime, std::thread::id messageThreadId)
std::chrono::time_point< std::chrono::system_clock > GetMessageTime() const
The message time of the log statement.
std::thread::id GetMessageThreadId() const
The thread id of the log statement.
const std::string & GetLogMessage() const
The message for the log statement.
const std::string & GetFile() const
The file name for the log statement.
const std::string & GetFunction() const
The function name for the log statement.
LogLevel GetLevel() const
The log level for the log statement.
int32_t GetLine() const
The line number for the log statement.
LogLevel
Different log levels used across the MIP SDK.
MIP namespace macros.