V.06 11/3

Dependencies:   FT6206 SDFileSystem SPI_TFT_ILI9341 TFT_fonts

Fork of ATT_AWS_IoT_demo by attiot

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers aws_iot_log.h Source File

aws_iot_log.h

Go to the documentation of this file.
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 //#define IOT_DEBUG 
00048  
00049 #ifdef IOT_DEBUG
00050 #define DEBUG(...)    \
00051     {\
00052     printf("DEBUG:   %s L#%d ", __PRETTY_FUNCTION__, __LINE__);  \
00053     printf(__VA_ARGS__); \
00054     printf("\n"); \
00055     }
00056 #else
00057 
00058 #if DEBUG_LEVEL > 0
00059 #define DEBUG(...)  pc_print(__VA_ARGS__); \
00060                     pc_print("\r\n");   
00061 #else
00062 #define DEBUG(...)  
00063 #endif
00064 
00065 #endif
00066 
00067 /**
00068  * @brief Info level logging macro.
00069  *
00070  * Macro to expose desired log message.  Info messages do not include automatic function names and line numbers.
00071  */
00072 #ifdef IOT_INFO
00073 #define INFO(...)    \
00074     {\
00075     printf(__VA_ARGS__); \
00076     printf("\n"); \
00077     }
00078 #else
00079 #define INFO(...) pc_print(__VA_ARGS__); \
00080                   pc_print("\r\n");
00081 #endif
00082 
00083 /**
00084  * @brief Warn level logging macro.
00085  *
00086  * Macro to expose function, line number as well as desired log message.
00087  */
00088 #ifdef IOT_WARN
00089 #define WARN(...)   \
00090     { \
00091     printf("WARN:  %s L#%d ", __PRETTY_FUNCTION__, __LINE__);  \
00092     printf(__VA_ARGS__); \
00093     printf("\n"); \
00094     }
00095 #else
00096 #define WARN(...) pc_print("WARN: ");  \
00097                   pc_print(__VA_ARGS__); \
00098                   pc_print("\r\n");
00099 #endif
00100 
00101 /**
00102  * @brief Error level logging macro.
00103  *
00104  * Macro to expose function, line number as well as desired log message.
00105  */
00106 #ifdef IOT_ERROR
00107 #define ERROR(...)  \
00108     { \
00109     printf("ERROR: %s L#%d ", __PRETTY_FUNCTION__, __LINE__); \
00110     printf(__VA_ARGS__); \
00111     printf("\n"); \
00112     }
00113 #else
00114 #define ERROR(...)  pc_print("ERROR: ");  \
00115                     pc_print(__VA_ARGS__); \
00116                     pc_print("\r\n");
00117 #endif
00118 
00119 #endif // _IOT_LOG_H
00120 
00121