Microsoft Information Protection (MIP) SDK for C: Reference 1.15
Doxygen-generated documentation for MIP SDK written in C
Loading...
Searching...
No Matches
logger_delegate_cc.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/**
29 * @brief Defines logger callback functions
30 *
31 * @file logger_delegate_cc.h
32 */
33
34#ifndef API_MIP_LOGGER_DELEGATE_CC_H_
35#define API_MIP_LOGGER_DELEGATE_CC_H_
36
38#include "mip_cc/error_cc.h"
40#include "mip_cc/result_cc.h"
41
42/**
43 * @brief Log level
44 */
45typedef enum {
46 MIP_LOG_LEVEL_TRACE = 0, /**< Trace */
47 MIP_LOG_LEVEL_INFO, /**< Info */
48 MIP_LOG_LEVEL_WARNING, /**< Warning */
49 MIP_LOG_LEVEL_ERROR, /**< Error */
51
52typedef struct {
53 int size; /*The size of this mip_cc_log_message_data. Used for versioning*/
54 mip_cc_log_level level; /*the log level for the log statement*/
55 const char* message; /*the message for the log statement*/
56 const char* function; /*the function name for the log statement*/
57 const char* file; /*the file name where log statement was generated.*/
58 int32_t line; /*the line number where the log statement was generated.*/
59 void* context; /*the logger context for the operation*/
60 int64_t milliSecondsSinceEpoch; /*the time that the log message was created in milliseconds since epoch (UTC)*/
61 const char* messageThreadId; /*The thread id that the message was created in*/
63
64/**
65 * @brief Callback function definition for initialization of logger
66 *
67 * @param storagePath File path where logs may be stored
68 */
69MIP_CC_CALLBACK(mip_cc_logger_init_callback_fn /*typename*/,
70 void /*return*/,
71 const char* /*storagePath*/);
72
73/**
74 * @brief Callback function definition for flushing logs to disk
75 */
76MIP_CC_CALLBACK(mip_cc_logger_flush_callback_fn /*typename*/,
77 void /*return*/);
78
79/**
80 * @brief Callback function definition for writing a log statement
81 *
82 * @param level the log level for the log statement.
83 * @param message the message for the log statement.
84 * @param function the function name for the log statement.
85 * @param file the file name where log statement was generated.
86 * @param line the line number where the log statement was generated.
87 */
88MIP_CC_CALLBACK(mip_cc_logger_write_callback_fn /*typename*/,
89 void /*return*/,
90 const mip_cc_log_level /*level*/,
91 const char* /*message*/,
92 const char* /*function*/,
93 const char* /*file*/,
94 const int32_t /*line*/);
95
96/**
97 * @brief Callback function definition for writing a log statement
98 *
99 * @param logMessageData The log data
100 */
101MIP_CC_CALLBACK(mip_cc_logger_write_with_message_data_callback_fn /*typename*/,
102 void /*return*/,
103 mip_cc_log_message_data logMessageData);
104
106
107/**
108 * @brief Creates a logger delegate which can be used to override MIP's default logger
109 *
110 * @param initCallback Function pointer for initialization
111 * @param flushCallback Function pointer for flushing logs
112 * @param writeCallback Function pointer for writing a log statement
113 * @param loggerDelegate [Output] Handle to logger delegate object
114 * @param errorInfo [Output] (Optional) Failure info if operation result is error
115 *
116 * @return Result code indicating success or failure
117 */
118MIP_CC_API(mip_cc_result) MIP_CC_CreateLoggerDelegate(
119 const mip_cc_logger_init_callback_fn initCallback,
120 const mip_cc_logger_flush_callback_fn flushCallback,
121 const mip_cc_logger_write_callback_fn writeCallback,
124
125typedef struct {
126 int size; /*The size of this mip_cc_create_logger_delegate_message_data_args. Used for versioning*/
127 mip_cc_logger_init_callback_fn initCallback; /*Function pointer for initialization*/
128 mip_cc_logger_flush_callback_fn flushCallback; /*Function pointer for flushing logs*/
129 mip_cc_logger_write_with_message_data_callback_fn writeCallback; /*Function pointer for writing a log statement*/
130 mip_cc_logger_delegate* loggerDelegate; /*[Output] Handle to logger delegate object*/
131 mip_cc_error* errorInfo; /*[Output] (Optional) Failure info if operation result is error*/
133
134/**
135 * @brief Creates a logger delegate which can be used to override MIP's default logger
136 *
137 * @param methodargs Arguments to this function
138 *
139 * @return Result code indicating success or failure
140 */
141MIP_CC_API(mip_cc_result) MIP_CC_CreateLoggerDelegateMessageData(
143
144/**
145 * @brief Release resources associated with an logger delegate handle
146 *
147 * @param loggerDelegate logger delegate to be released
148 */
149MIP_CC_API(void) MIP_CC_ReleaseLoggerDelegate(mip_cc_logger_delegate loggerDelegate);
150
151#endif // API_MIP_LOGGER_DELEGATE_CC_H_
A file Containing the common types used by the upe, file and protection modules.
Error definition and functions.
const mip_cc_logger_flush_callback_fn const mip_cc_logger_write_callback_fn writeCallback
mip_cc_handle * mip_cc_logger_delegate
mip_cc_log_level
Log level.
@ MIP_LOG_LEVEL_TRACE
Trace.
@ MIP_LOG_LEVEL_INFO
Info.
@ MIP_LOG_LEVEL_ERROR
Error.
@ MIP_LOG_LEVEL_WARNING
Warning.
MIP_CC_API(void) MIP_CC_ReleaseLoggerDelegate(mip_cc_logger_delegate loggerDelegate)
Release resources associated with an logger delegate handle.
const mip_cc_logger_flush_callback_fn flushCallback
const mip_cc_logger_flush_callback_fn const mip_cc_logger_write_callback_fn mip_cc_logger_delegate mip_cc_error * errorInfo
const mip_cc_logger_flush_callback_fn const mip_cc_logger_write_callback_fn mip_cc_logger_delegate * loggerDelegate
MIP_CC_CALLBACK(mip_cc_logger_init_callback_fn, void, const char *)
Callback function definition for initialization of logger.
Export/import and other macros for C API.
Defines success/error result codes.
mip_cc_result
API success/failure result.
Definition result_cc.h:44
mip_cc_logger_write_with_message_data_callback_fn writeCallback
Error information.
Definition error_cc.h:79
Opaque handle to MIP object.