Avoid -if- in the LOG function

Hello All:
I have written a log function to the project. Depending on the level in the log function(INFO) it displays the message. But in the log fn. i have a -if- which is called each time log is being called( like having an -if- for each printf of C). Is there a way to avoid the
-if- in the log function.
My Log call looks like:

LOG(INFO,"This Belongs to INFO Mode");
//INFO is of enum type

Suggestions are Acknowledged:
With Regards:

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Wrong forum.

This is the wrong forum for your question. Try a C/C++ forum or newsgroup.

Use a Table

Since your INFO type is an enum it will have a value from 0..n, so you can create a table of options and then reference them using the enumerated value:


char *LogMsgTable[] = {
"This is in the INFO module",
"This is in the DEBUG module",
"This is in the MISC module"

#define LOG(x) fprintf(stderr, LogMsgTable[x])

No more if...