| 1 |
/* |
| 2 |
* Copyright (c) 2015, ARM Limited and Contributors. All rights reserved. |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: BSD-3-Clause |
| 5 |
*/ |
| 6 |
|
| 7 |
#ifndef DEBUG_H |
| 8 |
#define DEBUG_H |
| 9 |
|
| 10 |
#include <stdio.h> |
| 11 |
|
| 12 |
/* The log output macros print output to the console. These macros produce |
| 13 |
* compiled log output only if the LOG_LEVEL defined in the makefile (or the |
| 14 |
* make command line) is greater or equal than the level required for that |
| 15 |
* type of log output. |
| 16 |
* The format expected is the same as for printf(). For example: |
| 17 |
* INFO("Info %s.\n", "message") -> INFO: Info message. |
| 18 |
* WARN("Warning %s.\n", "message") -> WARNING: Warning message. |
| 19 |
*/ |
| 20 |
|
| 21 |
#define LOG_LEVEL_NONE 0 |
| 22 |
#define LOG_LEVEL_ERROR 10 |
| 23 |
#define LOG_LEVEL_NOTICE 20 |
| 24 |
#define LOG_LEVEL_WARNING 30 |
| 25 |
#define LOG_LEVEL_INFO 40 |
| 26 |
#define LOG_LEVEL_VERBOSE 50 |
| 27 |
|
| 28 |
|
| 29 |
#if LOG_LEVEL >= LOG_LEVEL_NOTICE |
| 30 |
# define NOTICE(...) printf("NOTICE: " __VA_ARGS__) |
| 31 |
#else |
| 32 |
# define NOTICE(...) |
| 33 |
#endif |
| 34 |
|
| 35 |
#if LOG_LEVEL >= LOG_LEVEL_ERROR |
| 36 |
# define ERROR(...) printf("ERROR: " __VA_ARGS__) |
| 37 |
#else |
| 38 |
# define ERROR(...) |
| 39 |
#endif |
| 40 |
|
| 41 |
#if LOG_LEVEL >= LOG_LEVEL_WARNING |
| 42 |
# define WARN(...) printf("WARNING: " __VA_ARGS__) |
| 43 |
#else |
| 44 |
# define WARN(...) |
| 45 |
#endif |
| 46 |
|
| 47 |
#if LOG_LEVEL >= LOG_LEVEL_INFO |
| 48 |
# define INFO(...) printf("INFO: " __VA_ARGS__) |
| 49 |
#else |
| 50 |
# define INFO(...) |
| 51 |
#endif |
| 52 |
|
| 53 |
#if LOG_LEVEL >= LOG_LEVEL_VERBOSE |
| 54 |
# define VERBOSE(...) printf("VERBOSE: " __VA_ARGS__) |
| 55 |
#else |
| 56 |
# define VERBOSE(...) |
| 57 |
#endif |
| 58 |
|
| 59 |
#endif /* DEBUG_H */ |