Azure SDK for Embedded C
az_log.h
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // SPDX-License-Identifier: MIT
3 
20 #ifndef _az_LOG_H
21 #define _az_LOG_H
22 
23 #include <azure/core/az_result.h>
24 #include <azure/core/az_span.h>
25 
26 #include <stdint.h>
27 
28 #include <azure/core/_az_cfg_prefix.h>
29 
30 #define _az_LOG_MAKE_CLASSIFICATION(facility, code) \
31  ((int32_t)((uint32_t)(facility) << 16) | (uint32_t)(code))
32 
36 // Make sure to update #_az_log_classifications_are_valid() whenever a new value is added to this
37 // enum.
38 typedef enum
39 {
41  = -1,
42 
44  = _az_LOG_MAKE_CLASSIFICATION(_az_FACILITY_HTTP, 1),
45 
47  = _az_LOG_MAKE_CLASSIFICATION(_az_FACILITY_HTTP, 2),
48 
49  AZ_LOG_HTTP_RETRY = _az_LOG_MAKE_CLASSIFICATION(
50  _az_FACILITY_HTTP,
51  3),
52 
54  = _az_LOG_MAKE_CLASSIFICATION(_az_FACILITY_MQTT, 1),
55 
57  = _az_LOG_MAKE_CLASSIFICATION(_az_FACILITY_MQTT, 2),
58 
59  AZ_LOG_IOT_RETRY = _az_LOG_MAKE_CLASSIFICATION(_az_FACILITY_IOT, 1),
60 
62  = _az_LOG_MAKE_CLASSIFICATION(_az_FACILITY_IOT, 2),
63 
65  = _az_LOG_MAKE_CLASSIFICATION(_az_FACILITY_IOT, 3),
67 
75 typedef void (*az_log_message_fn)(az_log_classification classification, az_span message);
76 
87 #ifndef AZ_NO_LOGGING
88 void az_log_set_classifications(az_log_classification const classifications[]);
89 #else
90 AZ_INLINE void az_log_set_classifications(az_log_classification const classifications[])
91 {
92  (void)classifications;
93 }
94 #endif // AZ_NO_LOGGING
95 
103 #ifndef AZ_NO_LOGGING
104 void az_log_set_callback(az_log_message_fn az_log_message_callback);
105 #else
106 AZ_INLINE void az_log_set_callback(az_log_message_fn az_log_message_callback)
107 {
108  (void)az_log_message_callback;
109 }
110 #endif // AZ_NO_LOGGING
111 
112 #include <azure/core/_az_cfg_suffix.h>
113 
114 #endif // _az_LOG_H
AZ_LOG_HTTP_REQUEST
@ AZ_LOG_HTTP_REQUEST
HTTP request is about to be sent.
Definition: az_log.h:43
az_result.h
Definition of az_result and helper functions.
AZ_LOG_IOT_SAS_TOKEN
@ AZ_LOG_IOT_SAS_TOKEN
IoT Client generated new SAS token.
Definition: az_log.h:61
az_log_classification
az_log_classification
Identifies the classifications of log messages produced by the SDK.
Definition: az_log.h:39
AZ_LOG_END_OF_LIST
@ AZ_LOG_END_OF_LIST
Terminates the classification array passed to az_log_set_classifications().
Definition: az_log.h:40
az_log_message_fn
void(* az_log_message_fn)(az_log_classification classification, az_span message)
Defines the signature of the callback function that application developers must write in order to rec...
Definition: az_log.h:75
AZ_LOG_MQTT_RECEIVED_TOPIC
@ AZ_LOG_MQTT_RECEIVED_TOPIC
Accepted MQTT topic received.
Definition: az_log.h:53
az_log_set_classifications
void az_log_set_classifications(az_log_classification const classifications[])
Allows the application to specify which az_log_classification types it is interested in receiving.
AZ_LOG_MQTT_RECEIVED_PAYLOAD
@ AZ_LOG_MQTT_RECEIVED_PAYLOAD
Accepted MQTT payload received.
Definition: az_log.h:56
AZ_LOG_HTTP_RESPONSE
@ AZ_LOG_HTTP_RESPONSE
HTTP response was received.
Definition: az_log.h:46
az_span.h
An az_span represents a contiguous byte buffer and is used for string manipulations,...
AZ_LOG_HTTP_RETRY
@ AZ_LOG_HTTP_RETRY
First HTTP request did not succeed and will be retried.
Definition: az_log.h:49
AZ_LOG_IOT_RETRY
@ AZ_LOG_IOT_RETRY
IoT Client retry.
Definition: az_log.h:59
az_log_set_callback
void az_log_set_callback(az_log_message_fn az_log_message_callback)
Sets the function that will be invoked to report an SDK log message.
AZ_LOG_IOT_AZURERTOS
@ AZ_LOG_IOT_AZURERTOS
Azure IoT classification for Azure RTOS.
Definition: az_log.h:64
az_span
Represents a "view" over a byte buffer that represents a contiguous region of memory....
Definition: az_span.h:33