SmartMesh QSL for STM32F4 version

Fork of COG-AD4050_QSL by APS Lab

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers dn_debug.h Source File

dn_debug.h

00001 /*
00002 Copyright (c) 2016, Dust Networks. All rights reserved.
00003 
00004 Debug macros (based on http://c.learncodethehardway.org/book/ex20.html ).
00005 
00006 \license See attached DN_LICENSE.txt.
00007 */
00008 
00009 #ifndef DN_DEBUG_H
00010 #define DN_DEBUG_H
00011 
00012 #include <stdio.h>
00013 #include <errno.h>
00014 #include <string.h>
00015 
00016 /* Comment out this define to include debug messages */
00017 #define NDEBUG 0
00018 
00019 /* Comment out this define to include log messages */
00020 #define NLOG 0
00021 
00022 #if 1
00023 #ifdef NDEBUG
00024 //#define debug(M, ...) do {}while(0)
00025 #else
00026 #define debug(M, ...)   fprintf(stderr, "DEBUG %s:%d: " M "\r\n", __FILE__, __LINE__, ##__VA_ARGS__)
00027 #endif
00028 
00029 #define clean_errno() (errno == 0 ? "None" : strerror(errno))
00030 
00031 #ifdef NLOG
00032 //#define log_err(M, ...)       do {}while(0)
00033 //#define log_warn(M, ...)  do {}while(0)
00034 //#define log_info(M, ...)  do {}while(0)
00035 #else
00036 #define log_err(M, ...)     fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " M "\r\n", __FILE__, __LINE__, clean_errno(), ##__VA_ARGS__)
00037 #define log_warn(M, ...)    fprintf(stderr, "[WARN] (%s:%d: errno: %s) " M "\r\n", __FILE__, __LINE__, clean_errno(), ##__VA_ARGS__)
00038 #define log_info(M, ...)    fprintf(stderr, "[INFO] (%s:%d) " M "\r\n", __FILE__, __LINE__, ##__VA_ARGS__)
00039 #endif
00040 
00041 #endif
00042 
00043 #endif
00044