mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
improved server logging. "logfile" is gone from qw-server to be replaced
with "sv_logfile" and thus giving nq-server logging as well.
This commit is contained in:
parent
c05db51069
commit
0963c2476d
4 changed files with 38 additions and 29 deletions
|
@ -64,11 +64,17 @@ static const char rcsid[] =
|
|||
#include "QF/plugin.h"
|
||||
#include "QF/qtypes.h"
|
||||
#include "QF/sys.h"
|
||||
#include "QF/va.h"
|
||||
#include "QF/vfile.h"
|
||||
#include "QF/vfs.h"
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
static console_data_t con_data;
|
||||
|
||||
static VFile *log_file;
|
||||
static cvar_t *sv_logfile;
|
||||
|
||||
#ifdef HAVE_CURSES_H
|
||||
static int use_curses = 1;
|
||||
|
||||
|
@ -221,6 +227,27 @@ sigwinch (int sig)
|
|||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
sv_logfile_f (cvar_t *var)
|
||||
{
|
||||
if (strequal (var->string, "none")) {
|
||||
if (log_file)
|
||||
Qclose (log_file);
|
||||
log_file = 0;
|
||||
} else {
|
||||
char *fname = strdup (var->string);
|
||||
char *flags = strrchr (fname, ':');
|
||||
|
||||
if (flags)
|
||||
*flags++ = 0;
|
||||
else
|
||||
flags = "";
|
||||
flags = nva ("a%s", flags);
|
||||
log_file = Qopen (va ("%s/%s", fs_userpath->string, fname), flags);
|
||||
free (flags);
|
||||
free (fname);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
C_Init (void)
|
||||
|
@ -288,11 +315,18 @@ C_Init (void)
|
|||
} else
|
||||
#endif
|
||||
setvbuf (stdout, 0, _IOLBF, BUFSIZ);
|
||||
sv_logfile = Cvar_Get ("sv_logfile", "none", CVAR_NONE, sv_logfile_f,
|
||||
"Control server console logging. \"none\" for off, "
|
||||
"or \"filename:gzflags\"");
|
||||
}
|
||||
|
||||
static void
|
||||
C_Shutdown (void)
|
||||
{
|
||||
if (log_file) {
|
||||
Qclose (log_file);
|
||||
log_file = 0;
|
||||
}
|
||||
#ifdef HAVE_CURSES_H
|
||||
if (use_curses)
|
||||
endwin ();
|
||||
|
@ -311,6 +345,9 @@ C_Print (const char *fmt, va_list args)
|
|||
dvsprintf (buffer, fmt, args);
|
||||
|
||||
txt = buffer->str;
|
||||
|
||||
if (log_file)
|
||||
Qputs (log_file, buffer->str);
|
||||
#ifdef HAVE_CURSES_H
|
||||
if (use_curses) {
|
||||
Con_BufferAddText (output_buffer, buffer->str);
|
||||
|
|
|
@ -187,25 +187,6 @@ SV_Quit_f (void)
|
|||
Sys_Quit ();
|
||||
}
|
||||
|
||||
void
|
||||
SV_Logfile_f (void)
|
||||
{
|
||||
char name[MAX_OSPATH];
|
||||
|
||||
if (sv_logfile) {
|
||||
SV_Printf ("File logging off.\n");
|
||||
Qclose (sv_logfile);
|
||||
sv_logfile = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
snprintf (name, sizeof (name), "%s/qconsole.log", com_gamedir);
|
||||
SV_Printf ("Logging text to %s.\n", name);
|
||||
sv_logfile = Qopen (name, "w");
|
||||
if (!sv_logfile)
|
||||
SV_Printf ("failed.\n");
|
||||
}
|
||||
|
||||
void
|
||||
SV_Fraglogfile_f (void)
|
||||
{
|
||||
|
@ -1107,8 +1088,6 @@ SV_InitOperatorCommands (void)
|
|||
Info_SetValueForStarKey (svs.info, "*cheats", "ON", 0);
|
||||
}
|
||||
|
||||
Cmd_AddCommand ("logfile", SV_Logfile_f, "Toggles logging of console text "
|
||||
"to qconsole.log");
|
||||
Cmd_AddCommand ("fraglogfile", SV_Fraglogfile_f, "Enables logging of kills "
|
||||
"to frag_##.log");
|
||||
|
||||
|
|
|
@ -187,7 +187,6 @@ cvar_t *watervis;
|
|||
|
||||
cvar_t *hostname;
|
||||
|
||||
VFile *sv_logfile;
|
||||
VFile *sv_fraglogfile;
|
||||
|
||||
cvar_t *pr_gc;
|
||||
|
@ -231,13 +230,9 @@ void
|
|||
SV_Shutdown (void)
|
||||
{
|
||||
Master_Shutdown ();
|
||||
if (sv_logfile) {
|
||||
Qclose (sv_logfile);
|
||||
sv_logfile = NULL;
|
||||
}
|
||||
if (sv_fraglogfile) {
|
||||
Qclose (sv_fraglogfile);
|
||||
sv_logfile = NULL;
|
||||
sv_fraglogfile = NULL;
|
||||
}
|
||||
NET_Shutdown ();
|
||||
Con_Shutdown ();
|
||||
|
|
|
@ -195,8 +195,6 @@ SV_Print (const char *fmt, va_list args)
|
|||
}
|
||||
|
||||
Con_Printf ("%s", msg2); // also echo to debugging console
|
||||
if (sv_logfile)
|
||||
Qprintf (sv_logfile, "%s", msg2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue