Aaron Durbin | d38e3de | 2015-10-01 14:25:19 -0500 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright 2015 Google Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
Aaron Durbin | d38e3de | 2015-10-01 14:25:19 -0500 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #ifndef _CBFSTOOL_CONSOLE_H_ |
| 17 | #define _CBFSTOOL_CONSOLE_H_ |
| 18 | |
| 19 | #include <stdio.h> |
| 20 | #include <commonlib/loglevel.h> |
| 21 | |
| 22 | /* Message output */ |
| 23 | extern int verbose; |
| 24 | #define ERROR(...) { fprintf(stderr, "E: " __VA_ARGS__); } |
| 25 | #define WARN(...) { fprintf(stderr, "W: " __VA_ARGS__); } |
| 26 | #define LOG(...) { fprintf(stderr, __VA_ARGS__); } |
| 27 | #define INFO(...) { if (verbose > 0) fprintf(stderr, "INFO: " __VA_ARGS__); } |
| 28 | #define DEBUG(...) { if (verbose > 1) fprintf(stderr, "DEBUG: " __VA_ARGS__); } |
| 29 | |
| 30 | |
| 31 | #define printk(lvl, ...) \ |
| 32 | { \ |
| 33 | if ((lvl) <= BIOS_ERR) { \ |
| 34 | ERROR(__VA_ARGS__); \ |
| 35 | } else if ((lvl) <= BIOS_NOTICE) { \ |
| 36 | WARN(__VA_ARGS__); \ |
| 37 | } else if ((lvl) <= BIOS_INFO) { \ |
| 38 | INFO(__VA_ARGS__); \ |
| 39 | } else if ((lvl) <= BIOS_DEBUG) { \ |
| 40 | DEBUG(__VA_ARGS__); \ |
| 41 | } \ |
| 42 | } |
| 43 | |
| 44 | #endif |
| 45 | |