Skip to content

Commit

Permalink
Get debug mode from the HEXCHAT_DEBUG environment variable
Browse files Browse the repository at this point in the history
Debug mode gets enabled when this variable is set to a nonempty string.

Additionally, if it set to a valid debug domain, that domain will be
used as a set value to G_MESSAGES_DEBUG instead of "all".

Currently recognized domains are "error", "warning", "critical",
"message", "info", "debug", and the special domain "all".
  • Loading branch information
konsolebox committed Apr 30, 2024
1 parent 2d104a1 commit 15b8947
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/common/hexchat.c
Original file line number Diff line number Diff line change
Expand Up @@ -1026,11 +1026,31 @@ set_locale (void)
#endif
}

static gboolean is_valid_debug_domain (const gchar *domain)
{
static const gchar *valid_domains[] = { "error", "warning", "critical", "message", "info",
"debug", "all", NULL };
const gchar **iter;

if (domain != NULL)
for (iter = valid_domains; *iter != NULL; ++iter)
if (g_strcmp0 (domain, *iter) == 0)
return TRUE;

return FALSE;
}

int
main (int argc, char *argv[])
{
int i;
int ret;
const char *env;

env = g_getenv("HEXCHAT_DEBUG");

if (env != NULL && *env != '\0')
g_setenv("G_MESSAGES_DEBUG", is_valid_debug_domain (env) ? env : "all", TRUE);

#ifdef WIN32
HRESULT coinit_result;
Expand Down

0 comments on commit 15b8947

Please sign in to comment.