blob: 8e4fbc27e2a6b69db8108de81088def5189a9d0e [file] [log] [blame]
Aaron Durbind38e3de2015-10-01 14:25:19 -05001/*
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 Durbind38e3de2015-10-01 14:25:19 -050014 */
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 */
23extern 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