1 /******************************************************************************* 2 * Copyright (c) 2014 IBM Corp. 3 * 4 * All rights reserved. This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License v1.0 6 * and Eclipse Distribution License v1.0 which accompany this distribution. 7 * 8 * The Eclipse Public License is available at 9 * http://www.eclipse.org/legal/epl-v10.html 10 * and the Eclipse Distribution License is available at 11 * http://www.eclipse.org/org/documents/edl-v10.php. 12 * 13 * Contributors: 14 * Ian Craggs - initial API and implementation and/or initial documentation 15 *******************************************************************************/ 16 17 #if !defined(MQTT_LOGGING_H) 18 #define MQTT_LOGGING_H 19 20 #define STREAM stdout 21 #if !defined(DEBUG) 22 #define DEBUG(...) \ 23 {\ 24 fprintf(STREAM, "DEBUG: %s L#%d ", __PRETTY_FUNCTION__, __LINE__); \ 25 fprintf(STREAM, ##__VA_ARGS__); \ 26 fflush(STREAM); \ 27 } 28 #endif 29 #if !defined(LOG) 30 #define LOG(...) \ 31 {\ 32 fprintf(STREAM, "LOG: %s L#%d ", __PRETTY_FUNCTION__, __LINE__); \ 33 fprintf(STREAM, ##__VA_ARGS__); \ 34 fflush(STREAM); \ 35 } 36 #endif 37 #if !defined(WARN) 38 #define WARN(...) \ 39 { \ 40 fprintf(STREAM, "WARN: %s L#%d ", __PRETTY_FUNCTION__, __LINE__); \ 41 fprintf(STREAM, ##__VA_ARGS__); \ 42 fflush(STREAM); \ 43 } 44 #endif 45 #if !defined(ERROR) 46 #define ERROR(...) \ 47 { \ 48 fprintf(STREAM, "ERROR: %s L#%d ", __PRETTY_FUNCTION__, __LINE__); \ 49 fprintf(STREAM, ##__VA_ARGS__); \ 50 fflush(STREAM); \ 51 exit(1); \ 52 } 53 #endif 54 55 #endif 56