Demo application for using the AT&T IoT Starter Kit Powered by AWS.
Dependencies: SDFileSystem
Fork of ATT_AWS_IoT_demo 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 // Change to a number between 1 and 4 to debug the TLS connection 00029 // WARNING: the large number of prints may cause timeouts during the connection. 00030 #define DEBUG_LEVEL 0 00031 00032 #ifndef _IOT_LOG_H 00033 #define _IOT_LOG_H 00034 00035 #include <stdio.h> 00036 #include <stdlib.h> 00037 #include "platform.h" 00038 00039 // Exposes USB Serial function 00040 void pc_print(const char * format, ...); 00041 00042 /** 00043 * @brief Debug level logging macro. 00044 * 00045 * Macro to expose function, line number as well as desired log message. 00046 */ 00047 #ifdef IOT_DEBUG 00048 #define DEBUG(...) \ 00049 {\ 00050 printf("DEBUG: %s L#%d ", __PRETTY_FUNCTION__, __LINE__); \ 00051 printf(__VA_ARGS__); \ 00052 printf("\n"); \ 00053 } 00054 #else 00055 00056 #if DEBUG_LEVEL > 0 00057 #define DEBUG(...) pc_print(__VA_ARGS__); \ 00058 pc_print("\r\n"); 00059 #else 00060 #define DEBUG(...) 00061 #endif 00062 00063 #endif 00064 00065 /** 00066 * @brief Info level logging macro. 00067 * 00068 * Macro to expose desired log message. Info messages do not include automatic function names and line numbers. 00069 */ 00070 #ifdef IOT_INFO 00071 #define INFO(...) \ 00072 {\ 00073 printf(__VA_ARGS__); \ 00074 printf("\n"); \ 00075 } 00076 #else 00077 #define INFO(...) pc_print(__VA_ARGS__); \ 00078 pc_print("\r\n"); 00079 #endif 00080 00081 /** 00082 * @brief Warn level logging macro. 00083 * 00084 * Macro to expose function, line number as well as desired log message. 00085 */ 00086 #ifdef IOT_WARN 00087 #define WARN(...) \ 00088 { \ 00089 printf("WARN: %s L#%d ", __PRETTY_FUNCTION__, __LINE__); \ 00090 printf(__VA_ARGS__); \ 00091 printf("\n"); \ 00092 } 00093 #else 00094 #define WARN(...) pc_print("WARN: "); \ 00095 pc_print(__VA_ARGS__); \ 00096 pc_print("\r\n"); 00097 #endif 00098 00099 /** 00100 * @brief Error level logging macro. 00101 * 00102 * Macro to expose function, line number as well as desired log message. 00103 */ 00104 #ifdef IOT_ERROR 00105 #define ERROR(...) \ 00106 { \ 00107 printf("ERROR: %s L#%d ", __PRETTY_FUNCTION__, __LINE__); \ 00108 printf(__VA_ARGS__); \ 00109 printf("\n"); \ 00110 } 00111 #else 00112 #define ERROR(...) pc_print("ERROR: "); \ 00113 pc_print(__VA_ARGS__); \ 00114 pc_print("\r\n"); 00115 #endif 00116 00117 #endif // _IOT_LOG_H 00118 00119
Generated on Tue Jul 12 2022 22:13:20 by 1.7.2