Lorenzo Maiorfi / XBeeLib_Fixed

Dependents:   XBeeZB_Receive_Data

Fork of XBeeLib by Digi International Inc.

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Debug.h Source File

Debug.h

00001 /**
00002  * Copyright (c) 2015 Digi International Inc.,
00003  * All rights not expressly granted are reserved.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
00007  * You can obtain one at http://mozilla.org/MPL/2.0/.
00008  *
00009  * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
00010  * =======================================================================
00011  */
00012 
00013 #if !defined(__DEBUG_H_)
00014 #define __DEBUG_H_
00015 
00016 #include "config.h"
00017 
00018 
00019 #if defined(ENABLE_THREAD_SAFE_LOGGING)
00020 
00021 #include "mbed.h"
00022 
00023 extern EventQueue s_logging_event_queue;
00024 
00025 #endif
00026 
00027 
00028 #if defined(ENABLE_LOGGING)
00029 
00030 #include "DigiLogger.h"
00031 
00032 #if !(defined(ENABLE_THREAD_SAFE_LOGGING))
00033 
00034 #define digi_log(...)  DigiLog::DigiLogger::log_format(__VA_ARGS__);
00035 
00036 #else
00037 
00038 #define digi_log(...)  s_logging_event_queue.call(&DigiLog::DigiLogger::log_format, __VA_ARGS__);
00039 
00040 #endif
00041 
00042 #else
00043 #define digi_log(...)  do {} while(0)
00044 #endif
00045 
00046 #if defined(ENABLE_ASSERTIONS)
00047 #include "mbed.h"
00048 #if !(defined assert)
00049 
00050 #if !(defined(ENABLE_THREAD_SAFE_LOGGING))
00051 
00052     #define assert(expr)        if (!(expr)) {                                      \
00053                                     DigiLog::DigiLogger::log_format(LogLevelNone, "Assertion failed: %s, file %s, line %d\n", \
00054                                          #expr, __FILE__, __LINE__);                \
00055                                     mbed_die();                                     \
00056                                 }
00057 
00058 #else
00059 
00060     #define assert(expr)        if (!(expr)) {                                      \
00061                                     s_logging_event_queue.call(&DigiLog::DigiLogger::log_format, LogLevelNone, "Assertion failed: %s, file %s, line %d\n", #expr, __FILE__, __LINE__ ); \
00062                                     mbed_die();                                     \
00063                                 }
00064 
00065 #endif
00066 
00067 #endif
00068 #else
00069 #define assert(expr)
00070 #endif
00071 
00072 #endif /* __DEBUG_H_ */