From b8993c5f0de4c62c7ed9718612f028ad27fd31d9 Mon Sep 17 00:00:00 2001 From: Jakob Gruber Date: Thu, 2 Aug 2012 09:49:34 +0200 Subject: [PATCH] core: Introduce a logging macro AVR_LOG() This works in conjunction with avr->log to tune out messages we are not interested in. LOG_ERROR is the default level. --- simavr/sim/sim_avr.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/simavr/sim/sim_avr.h b/simavr/sim/sim_avr.h index 737b3ce..db41e41 100644 --- a/simavr/sim/sim_avr.h +++ b/simavr/sim/sim_avr.h @@ -61,6 +61,21 @@ enum { #define AVR_DATA_TO_IO(v) ((v) - 32) #define AVR_IO_TO_DATA(v) ((v) + 32) +/** + * Logging macros and associated log levels. + * The current log level is kept in avr->log. + */ +enum { + LOG_ERROR = 1, + LOG_WARNING, + LOG_TRACE, +}; +#define AVR_LOG(avr, level, ...) \ + do { \ + if (avr->log >= level) \ + fprintf(stdout, __VA_ARGS__); \ + } while(0) + /* * Core states. */ -- 2.39.5