blob: ee8f1f51786fe70fc07d9635e084fcd45c2b7d45 [file] [log] [blame]
Juan Castillo11abdcd2014-10-21 11:30:42 +01001/*
2 * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
3 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Juan Castillo11abdcd2014-10-21 11:30:42 +01005 */
6
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +00007#ifndef DEBUG_H
8#define DEBUG_H
Juan Castillo11abdcd2014-10-21 11:30:42 +01009
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
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +000059#endif /* DEBUG_H */