I am writing a function as follows:
bool abc::GetLoggingStatus() {
//true or false is returned
int value;
if (regKey->HasValue("LoggingStatus")) {
regKey->QueryValue("LoggingStatus", &value);
if (value == 1)
return true; //no logging possible
else
return false;
}
regKey->SetValue("LoggingStatus", 1);
return true;
}
Logging level is defined as:
typedef enum {
Entry,
Exit,
Debug,
Warning,
Notification,
Error
} TYPE;
What I need if I select 1 the levels for logging must be shown namely debug,error … In regedit and if 0 nothing should be shown and logging be disabled.
You can’t create dropdown menus in regedit, but what you can do is create a new entry called
LoggingLevel. This entry is ignored ifLoggingStatusis 0.LoggingLevelis a string defining the level.If you want to convert this string back to an enum, the easiest way is to create a map from string to your Enum type:
In your code you query the logging level:
Of course you need to do appropriate error checking.
edit
You should add two function to get the log settings,
shouldLog()andgetLevel().The log function would then look like:
If you want to avoid complicated if-structures, you could also try and map the enums to a value and compare that. For example Warning = 1 and ALL = 0. Then you can check if
curLevel < typeto see if the logger should log.