Add log level to log executed macros

This commit is contained in:
WarmUpTill
2024-08-27 23:15:44 +02:00
committed by WarmUpTill
parent e729d15e97
commit 36fb83246b
8 changed files with 45 additions and 9 deletions

View File

@@ -524,6 +524,7 @@ void SwitcherData::SaveGeneralSettings(obs_data_t *obj)
static_cast<int>(autoStartEvent));
obs_data_set_int(obj, "logLevel", static_cast<int>(logLevel));
obs_data_set_int(obj, "logLevelVersion", 1);
obs_data_set_bool(obj, "showSystemTrayNotifications",
showSystemTrayNotifications);
obs_data_set_bool(obj, "disableHints", disableHints);
@@ -580,6 +581,25 @@ void SwitcherData::LoadGeneralSettings(obs_data_t *obj)
static_cast<AutoStart>(obs_data_get_int(obj, "autoStartEvent"));
logLevel = static_cast<LogLevel>(obs_data_get_int(obj, "logLevel"));
if (obs_data_get_int(obj, "logLevelVersion") < 1) {
enum OldLogLevel { DEFAULT, LOG_ACTION, VERBOSE };
OldLogLevel oldLogLevel = static_cast<OldLogLevel>(
obs_data_get_int(obj, "logLevel"));
switch (oldLogLevel) {
case DEFAULT:
logLevel = LogLevel::DEFAULT;
break;
case LOG_ACTION:
logLevel = LogLevel::LOG_ACTION;
break;
case VERBOSE:
logLevel = LogLevel::VERBOSE;
break;
default:
break;
}
}
showSystemTrayNotifications =
obs_data_get_bool(obj, "showSystemTrayNotifications");
disableHints = obs_data_get_bool(obj, "disableHints");

View File

@@ -368,13 +368,13 @@ bool Macro::RunActionsHelper(
bool Macro::RunActions(bool ignorePause)
{
vblog(LOG_INFO, "running actions of %s", _name.c_str());
mblog(LOG_INFO, "running actions of %s", _name.c_str());
return RunActionsHelper(_actions, ignorePause);
}
bool Macro::RunElseActions(bool ignorePause)
{
vblog(LOG_INFO, "running else actions of %s", _name.c_str());
mblog(LOG_INFO, "running else actions of %s", _name.c_str());
return RunActionsHelper(_elseActions, ignorePause);
}

View File

@@ -136,7 +136,7 @@ public:
bool transitionOverrideOverride = false;
bool adjustActiveTransitionType = true;
enum class LogLevel { DEFAULT, PRINT_ACTION, VERBOSE };
enum class LogLevel { DEFAULT, LOG_MACRO, LOG_ACTION, VERBOSE };
LogLevel logLevel = LogLevel::DEFAULT;
/* --- End of General tab section --- */

View File

@@ -12,9 +12,15 @@ bool VerboseLoggingEnabled()
bool ActionLoggingEnabled()
{
return GetSwitcher() &&
(GetSwitcher()->logLevel ==
SwitcherData::LogLevel::PRINT_ACTION ||
GetSwitcher()->logLevel == SwitcherData::LogLevel::VERBOSE);
(GetSwitcher()->logLevel == SwitcherData::LogLevel::LOG_ACTION ||
VerboseLoggingEnabled());
}
bool MacroLoggingEnabled()
{
return GetSwitcher() &&
(GetSwitcher()->logLevel == SwitcherData::LogLevel::LOG_MACRO ||
ActionLoggingEnabled());
}
} // namespace advss

View File

@@ -27,6 +27,13 @@ namespace advss {
blog(level, msg, ##__VA_ARGS__); \
} \
} while (0)
// Print log with "[adv-ss] " if log level is set to "macro", "action" or "verbose"
#define mblog(level, msg, ...) \
do { \
if (MacroLoggingEnabled()) { \
blog(level, msg, ##__VA_ARGS__); \
} \
} while (0)
#endif
@@ -34,5 +41,7 @@ namespace advss {
EXPORT bool VerboseLoggingEnabled();
// Returns true if log level is set to "action" or "verbose"
EXPORT bool ActionLoggingEnabled();
// Returns true if log level is set to "macro", "action" or "verbose"
EXPORT bool MacroLoggingEnabled();
} // namespace advss