Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of AWS-test by
aws_iot_log.h
00001 /* 00002 * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"). 00005 * You may not use this file except in compliance with the License. 00006 * A copy of the License is located at 00007 * 00008 * http://aws.amazon.com/apache2.0 00009 * 00010 * or in the "license" file accompanying this file. This file is distributed 00011 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 00012 * express or implied. See the License for the specific language governing 00013 * permissions and limitations under the License. 00014 */ 00015 00016 /** 00017 * @file aws_iot_log.h 00018 * @brief Logging macros for the SDK. 00019 * This file defines common logging macros with log levels to be used within the SDK. 00020 * These macros can also be used in the IoT application code as a common way to output 00021 * logs. The log levels can be tuned by modifying the makefile. Removing (commenting 00022 * out) the IOT_* statement in the makefile disables that log level. 00023 * 00024 * It is expected that the macros below will be modified or replaced when porting to 00025 * specific hardware platforms as printf may not be the desired behavior. 00026 */ 00027 00028 #ifndef _IOT_LOG_H 00029 #define _IOT_LOG_H 00030 00031 #ifdef __cplusplus 00032 extern "C" { 00033 #endif 00034 00035 #include <stdio.h> 00036 #include <stdlib.h> 00037 00038 /** 00039 * @brief Debug level logging macro. 00040 * 00041 * Macro to expose function, line number as well as desired log message. 00042 */ 00043 #ifdef ENABLE_IOT_DEBUG 00044 #define IOT_DEBUG(...) \ 00045 {\ 00046 printf("DEBUG: %s L#%d ", __func__, __LINE__); \ 00047 printf(__VA_ARGS__); \ 00048 printf("\n"); \ 00049 } 00050 #else 00051 #define IOT_DEBUG(...) 00052 #endif 00053 00054 /** 00055 * @brief Debug level trace logging macro. 00056 * 00057 * Macro to print message function entry and exit 00058 */ 00059 #ifdef ENABLE_IOT_TRACE 00060 #define FUNC_ENTRY \ 00061 {\ 00062 printf("FUNC_ENTRY: %s L#%d \n", __func__, __LINE__); \ 00063 } 00064 #define FUNC_EXIT \ 00065 {\ 00066 printf("FUNC_EXIT: %s L#%d \n", __func__, __LINE__); \ 00067 } 00068 #define FUNC_EXIT_RC(x) \ 00069 {\ 00070 printf("FUNC_EXIT: %s L#%d Return Code : %d \n", __func__, __LINE__, x); \ 00071 return x; \ 00072 } 00073 #else 00074 #define FUNC_ENTRY 00075 00076 #define FUNC_EXIT 00077 #define FUNC_EXIT_RC(x) { return x; } 00078 #endif 00079 00080 /** 00081 * @brief Info level logging macro. 00082 * 00083 * Macro to expose desired log message. Info messages do not include automatic function names and line numbers. 00084 */ 00085 #ifdef ENABLE_IOT_INFO 00086 #define IOT_INFO(...) \ 00087 {\ 00088 printf(__VA_ARGS__); \ 00089 printf("\n"); \ 00090 } 00091 #else 00092 #define IOT_INFO(...) 00093 #endif 00094 00095 /** 00096 * @brief Warn level logging macro. 00097 * 00098 * Macro to expose function, line number as well as desired log message. 00099 */ 00100 #ifdef ENABLE_IOT_WARN 00101 #define IOT_WARN(...) \ 00102 { \ 00103 printf("WARN: %s L#%d ", __func__, __LINE__); \ 00104 printf(__VA_ARGS__); \ 00105 printf("\n"); \ 00106 } 00107 #else 00108 #define IOT_WARN(...) 00109 #endif 00110 00111 /** 00112 * @brief Error level logging macro. 00113 * 00114 * Macro to expose function, line number as well as desired log message. 00115 */ 00116 #ifdef ENABLE_IOT_ERROR 00117 #define IOT_ERROR(...) \ 00118 { \ 00119 printf("ERROR: %s L#%d ", __func__, __LINE__); \ 00120 printf(__VA_ARGS__); \ 00121 printf("\n"); \ 00122 } 00123 #else 00124 #define IOT_ERROR(...) 00125 #endif 00126 00127 #ifdef __cplusplus 00128 } 00129 #endif 00130 00131 #endif // _IOT_LOG_H
Generated on Tue Jul 12 2022 11:16:36 by
1.7.2
