1*6f971622SJuan Castillo /* 2*6f971622SJuan Castillo * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved. 3*6f971622SJuan Castillo * 4*6f971622SJuan Castillo * Redistribution and use in source and binary forms, with or without 5*6f971622SJuan Castillo * modification, are permitted provided that the following conditions are met: 6*6f971622SJuan Castillo * 7*6f971622SJuan Castillo * Redistributions of source code must retain the above copyright notice, this 8*6f971622SJuan Castillo * list of conditions and the following disclaimer. 9*6f971622SJuan Castillo * 10*6f971622SJuan Castillo * Redistributions in binary form must reproduce the above copyright notice, 11*6f971622SJuan Castillo * this list of conditions and the following disclaimer in the documentation 12*6f971622SJuan Castillo * and/or other materials provided with the distribution. 13*6f971622SJuan Castillo * 14*6f971622SJuan Castillo * Neither the name of ARM nor the names of its contributors may be used 15*6f971622SJuan Castillo * to endorse or promote products derived from this software without specific 16*6f971622SJuan Castillo * prior written permission. 17*6f971622SJuan Castillo * 18*6f971622SJuan Castillo * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19*6f971622SJuan Castillo * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20*6f971622SJuan Castillo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21*6f971622SJuan Castillo * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 22*6f971622SJuan Castillo * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23*6f971622SJuan Castillo * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24*6f971622SJuan Castillo * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25*6f971622SJuan Castillo * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26*6f971622SJuan Castillo * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27*6f971622SJuan Castillo * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28*6f971622SJuan Castillo * POSSIBILITY OF SUCH DAMAGE. 29*6f971622SJuan Castillo */ 30*6f971622SJuan Castillo 31*6f971622SJuan Castillo #ifndef __DEBUG_H__ 32*6f971622SJuan Castillo #define __DEBUG_H__ 33*6f971622SJuan Castillo 34*6f971622SJuan Castillo #include <stdio.h> 35*6f971622SJuan Castillo 36*6f971622SJuan Castillo /* The log output macros print output to the console. These macros produce 37*6f971622SJuan Castillo * compiled log output only if the LOG_LEVEL defined in the makefile (or the 38*6f971622SJuan Castillo * make command line) is greater or equal than the level required for that 39*6f971622SJuan Castillo * type of log output. 40*6f971622SJuan Castillo * The format expected is the same as for printf(). For example: 41*6f971622SJuan Castillo * INFO("Info %s.\n", "message") -> INFO: Info message. 42*6f971622SJuan Castillo * WARN("Warning %s.\n", "message") -> WARNING: Warning message. 43*6f971622SJuan Castillo */ 44*6f971622SJuan Castillo 45*6f971622SJuan Castillo #define LOG_LEVEL_NONE 0 46*6f971622SJuan Castillo #define LOG_LEVEL_ERROR 10 47*6f971622SJuan Castillo #define LOG_LEVEL_NOTICE 20 48*6f971622SJuan Castillo #define LOG_LEVEL_WARNING 30 49*6f971622SJuan Castillo #define LOG_LEVEL_INFO 40 50*6f971622SJuan Castillo #define LOG_LEVEL_VERBOSE 50 51*6f971622SJuan Castillo 52*6f971622SJuan Castillo 53*6f971622SJuan Castillo #if LOG_LEVEL >= LOG_LEVEL_NOTICE 54*6f971622SJuan Castillo # define NOTICE(...) printf("NOTICE: " __VA_ARGS__) 55*6f971622SJuan Castillo #else 56*6f971622SJuan Castillo # define NOTICE(...) 57*6f971622SJuan Castillo #endif 58*6f971622SJuan Castillo 59*6f971622SJuan Castillo #if LOG_LEVEL >= LOG_LEVEL_ERROR 60*6f971622SJuan Castillo # define ERROR(...) printf("ERROR: " __VA_ARGS__) 61*6f971622SJuan Castillo #else 62*6f971622SJuan Castillo # define ERROR(...) 63*6f971622SJuan Castillo #endif 64*6f971622SJuan Castillo 65*6f971622SJuan Castillo #if LOG_LEVEL >= LOG_LEVEL_WARNING 66*6f971622SJuan Castillo # define WARN(...) printf("WARNING: " __VA_ARGS__) 67*6f971622SJuan Castillo #else 68*6f971622SJuan Castillo # define WARN(...) 69*6f971622SJuan Castillo #endif 70*6f971622SJuan Castillo 71*6f971622SJuan Castillo #if LOG_LEVEL >= LOG_LEVEL_INFO 72*6f971622SJuan Castillo # define INFO(...) printf("INFO: " __VA_ARGS__) 73*6f971622SJuan Castillo #else 74*6f971622SJuan Castillo # define INFO(...) 75*6f971622SJuan Castillo #endif 76*6f971622SJuan Castillo 77*6f971622SJuan Castillo #if LOG_LEVEL >= LOG_LEVEL_VERBOSE 78*6f971622SJuan Castillo # define VERBOSE(...) printf("VERBOSE: " __VA_ARGS__) 79*6f971622SJuan Castillo #else 80*6f971622SJuan Castillo # define VERBOSE(...) 81*6f971622SJuan Castillo #endif 82*6f971622SJuan Castillo 83*6f971622SJuan Castillo #endif /* __DEBUG_H__ */ 84