mirror of
https://github.com/EnergyMech/energymech.git
synced 2025-12-17 15:36:50 +00:00
turn on and off debug at runtime
This commit is contained in:
parent
3da107f0e4
commit
c95778523a
35
src/debug.c
35
src/debug.c
@ -1447,6 +1447,41 @@ int wrap_debug(void)
|
||||
|
||||
void do_debug(COMMAND_ARGS)
|
||||
{
|
||||
const char *arg;
|
||||
int m;
|
||||
|
||||
arg = chop(&rest);
|
||||
if (strcasecmp(arg,"off") == 0)
|
||||
{
|
||||
if (debugfile && debugfilemalloc == TRUE)
|
||||
Free(&debugfile);
|
||||
debugfilemalloc = FALSE;
|
||||
debugfile = NULL;
|
||||
dodebug = FALSE;
|
||||
to_user(from,"Debug output turned off");
|
||||
return;
|
||||
}
|
||||
if (strcasecmp(arg,"on") == 0)
|
||||
{
|
||||
m = is_safepath(rest,FILE_MAY_EXIST);
|
||||
debug("(do_debug) turn on, rest = '%s', %i\n",rest,m);
|
||||
if (*rest && m == FILE_IS_SAFE)
|
||||
{
|
||||
if (debugfile && debugfilemalloc == TRUE)
|
||||
Free(&debugfile);
|
||||
debugfilemalloc = TRUE;
|
||||
set_mallocdoer(do_debug);
|
||||
debugfile = strdup(rest);
|
||||
dodebug = TRUE;
|
||||
to_user(from,"Debug output turned on, Output = %s",rest);
|
||||
}
|
||||
else
|
||||
{
|
||||
to_user(from,"debug: Unsafe filename");
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
if (wrap_debug())
|
||||
to_user(from,"Debug information has been written to file");
|
||||
else
|
||||
|
||||
@ -184,6 +184,7 @@ BEG time_t ctcp_slot[CTCP_SLOTS];
|
||||
|
||||
BEG char debugbuf[MAXLEN];
|
||||
BEG char *debugfile MDEF(NULL);
|
||||
BEG int debugfilemalloc MDEF(FALSE);
|
||||
BEG int dodebug MDEF(FALSE);
|
||||
BEG int debug_fd MDEF(-1);
|
||||
BEG int debug_on_exit MDEF(FALSE);
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
|
||||
EnergyMech, IRC bot software
|
||||
Parts Copyright (c) 1997-2018 proton
|
||||
Parts Copyright (c) 1997-2025 proton
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user