IoT Home Alarm System

Dependents:   IoTBurglar_and_Fire_AlarmSystem

Committer:
kbrahmbhatt6
Date:
Fri Apr 29 06:59:59 2016 +0000
Revision:
0:2f388b030837
1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kbrahmbhatt6 0:2f388b030837 1 /* mbed Microcontroller Library
kbrahmbhatt6 0:2f388b030837 2 * Copyright (c) 2006-2013 ARM Limited
kbrahmbhatt6 0:2f388b030837 3 *
kbrahmbhatt6 0:2f388b030837 4 * Licensed under the Apache License, Version 2.0 (the "License");
kbrahmbhatt6 0:2f388b030837 5 * you may not use this file except in compliance with the License.
kbrahmbhatt6 0:2f388b030837 6 * You may obtain a copy of the License at
kbrahmbhatt6 0:2f388b030837 7 *
kbrahmbhatt6 0:2f388b030837 8 * http://www.apache.org/licenses/LICENSE-2.0
kbrahmbhatt6 0:2f388b030837 9 *
kbrahmbhatt6 0:2f388b030837 10 * Unless required by applicable law or agreed to in writing, software
kbrahmbhatt6 0:2f388b030837 11 * distributed under the License is distributed on an "AS IS" BASIS,
kbrahmbhatt6 0:2f388b030837 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
kbrahmbhatt6 0:2f388b030837 13 * See the License for the specific language governing permissions and
kbrahmbhatt6 0:2f388b030837 14 * limitations under the License.
kbrahmbhatt6 0:2f388b030837 15 */
kbrahmbhatt6 0:2f388b030837 16 #ifndef MBED_DEBUG_H
kbrahmbhatt6 0:2f388b030837 17 #define MBED_DEBUG_H
kbrahmbhatt6 0:2f388b030837 18 #include "device.h"
kbrahmbhatt6 0:2f388b030837 19
kbrahmbhatt6 0:2f388b030837 20 #ifdef __cplusplus
kbrahmbhatt6 0:2f388b030837 21 extern "C" {
kbrahmbhatt6 0:2f388b030837 22 #endif
kbrahmbhatt6 0:2f388b030837 23
kbrahmbhatt6 0:2f388b030837 24 #if DEVICE_STDIO_MESSAGES
kbrahmbhatt6 0:2f388b030837 25 #include <stdio.h>
kbrahmbhatt6 0:2f388b030837 26 #include <stdarg.h>
kbrahmbhatt6 0:2f388b030837 27
kbrahmbhatt6 0:2f388b030837 28 /** Output a debug message
kbrahmbhatt6 0:2f388b030837 29 *
kbrahmbhatt6 0:2f388b030837 30 * @param format printf-style format string, followed by variables
kbrahmbhatt6 0:2f388b030837 31 */
kbrahmbhatt6 0:2f388b030837 32 static inline void debug(const char *format, ...) {
kbrahmbhatt6 0:2f388b030837 33 va_list args;
kbrahmbhatt6 0:2f388b030837 34 va_start(args, format);
kbrahmbhatt6 0:2f388b030837 35 vfprintf(stderr, format, args);
kbrahmbhatt6 0:2f388b030837 36 va_end(args);
kbrahmbhatt6 0:2f388b030837 37 }
kbrahmbhatt6 0:2f388b030837 38
kbrahmbhatt6 0:2f388b030837 39 /** Conditionally output a debug message
kbrahmbhatt6 0:2f388b030837 40 *
kbrahmbhatt6 0:2f388b030837 41 * NOTE: If the condition is constant false (!= 1) and the compiler optimization
kbrahmbhatt6 0:2f388b030837 42 * level is greater than 0, then the whole function will be compiled away.
kbrahmbhatt6 0:2f388b030837 43 *
kbrahmbhatt6 0:2f388b030837 44 * @param condition output only if condition is true (== 1)
kbrahmbhatt6 0:2f388b030837 45 * @param format printf-style format string, followed by variables
kbrahmbhatt6 0:2f388b030837 46 */
kbrahmbhatt6 0:2f388b030837 47 static inline void debug_if(int condition, const char *format, ...) {
kbrahmbhatt6 0:2f388b030837 48 if (condition == 1) {
kbrahmbhatt6 0:2f388b030837 49 va_list args;
kbrahmbhatt6 0:2f388b030837 50 va_start(args, format);
kbrahmbhatt6 0:2f388b030837 51 vfprintf(stderr, format, args);
kbrahmbhatt6 0:2f388b030837 52 va_end(args);
kbrahmbhatt6 0:2f388b030837 53 }
kbrahmbhatt6 0:2f388b030837 54 }
kbrahmbhatt6 0:2f388b030837 55
kbrahmbhatt6 0:2f388b030837 56 #else
kbrahmbhatt6 0:2f388b030837 57 static inline void debug(const char *format, ...) {}
kbrahmbhatt6 0:2f388b030837 58 static inline void debug_if(int condition, const char *format, ...) {}
kbrahmbhatt6 0:2f388b030837 59
kbrahmbhatt6 0:2f388b030837 60 #endif
kbrahmbhatt6 0:2f388b030837 61
kbrahmbhatt6 0:2f388b030837 62 #ifdef __cplusplus
kbrahmbhatt6 0:2f388b030837 63 }
kbrahmbhatt6 0:2f388b030837 64 #endif
kbrahmbhatt6 0:2f388b030837 65
kbrahmbhatt6 0:2f388b030837 66 #endif