buserror / simavr

simavr is a lean, mean and hackable AVR simulator for linux & OSX
GNU General Public License v3.0
1.56k stars 365 forks source link

logger instead of printf #8

Closed ponty closed 11 years ago

ponty commented 11 years ago

It would be nice if a logger callback function could be passed to simavr. I can not redirect currently the stdout messages to Python logger in pysimavr.

Example (stdout is full of messages): http://ponty.github.com/pysimavr/usage.html#unit-test-example

schuay commented 11 years ago

A few patches have been added fairly recently that should alleviate this somewhat, see 33cb87d48e.

ponty commented 11 years ago

AVR_LOG would be perfect if I could set the logger function in it. Something like avr->logger(VA_ARGS) instead of fprintf(stdout, VA_ARGS)

#define AVR_LOG(avr, level, ...) \
    do { \
        if (avr->log >= level) \
            fprintf(stdout, __VA_ARGS__); \
    } while(0)

I searched the code and there are a lot of printf where AVR_LOG could be used.

schuay commented 11 years ago

Yes, AVR_LOG doesn't replace all printf calls, but it takes care of the most verbose message spam. Feel free to submit further patches.

buserror commented 11 years ago

I think this one was merged it quite some time ago, closing...