My program writes to a log and to stdout. Every message, however, has a certain priority and the user specifies in Preferences which priorities go to which stream (log or stdout
I think Jeff's idea is the way to go, but you can also accomplish this with a macro without using vprintf. This might require gcc:
#define write_log(priority,format,args...) \ if (priority & PRIO_LOG) { \ printf(format, ## args); \ }
Check here for info about how this works.