From: Jakob Gruber Date: Thu, 2 Aug 2012 07:49:34 +0000 (+0200) Subject: core: Introduce a logging macro AVR_LOG() X-Git-Tag: v1.0~31 X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=b8993c5f0de4c62c7ed9718612f028ad27fd31d9;p=sx%2Fsimavr.git 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. --- 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. */