2005-09-27 04:05:32 +00:00
|
|
|
// log.c: handles console logging functions and cvars
|
|
|
|
|
|
|
|
#include "quakedef.h"
|
|
|
|
|
2006-04-12 00:17:02 +00:00
|
|
|
// cvar callbacks
|
|
|
|
void Log_Dir_Callback (struct cvar_s *var, char *oldvalue);
|
|
|
|
void Log_Name_Callback (struct cvar_s *var, char *oldvalue);
|
|
|
|
|
2005-09-27 04:05:32 +00:00
|
|
|
// cvars
|
|
|
|
#define CONLOGGROUP "Console logging"
|
2010-07-11 02:22:39 +00:00
|
|
|
cvar_t log_enable[LOG_TYPES] = { CVARF("log_enable", "0", CVAR_NOTFROMSERVER),
|
|
|
|
CVARF("log_enable_players", "0", CVAR_NOTFROMSERVER)};
|
|
|
|
cvar_t log_name[LOG_TYPES] = { CVARFC("log_name", "", CVAR_NOTFROMSERVER, Log_Name_Callback),
|
|
|
|
CVARFC("log_name_players", "", CVAR_NOTFROMSERVER, Log_Name_Callback)};
|
|
|
|
cvar_t log_dir = CVARFC("log_dir", "", CVAR_NOTFROMSERVER, Log_Dir_Callback);
|
|
|
|
cvar_t log_readable = CVARF("log_readable", "0", CVAR_NOTFROMSERVER);
|
|
|
|
cvar_t log_developer = CVARF("log_developer", "0", CVAR_NOTFROMSERVER);
|
|
|
|
cvar_t log_rotate_files = CVARF("log_rotate_files", "0", CVAR_NOTFROMSERVER);
|
|
|
|
cvar_t log_rotate_size = CVARF("log_rotate_size", "131072", CVAR_NOTFROMSERVER);
|
|
|
|
cvar_t log_dosformat = CVARF("log_dosformat", "0", CVAR_NOTFROMSERVER);
|
2005-09-27 04:05:32 +00:00
|
|
|
|
|
|
|
// externals
|
|
|
|
extern char gamedirfile[];
|
|
|
|
|
|
|
|
// table of readable characters, same as ezquake
|
2006-03-04 20:43:48 +00:00
|
|
|
char readable[256] =
|
2005-09-27 04:05:32 +00:00
|
|
|
{
|
2006-03-04 20:43:48 +00:00
|
|
|
'.', '_', '_', '_', '_', '.', '_', '_',
|
|
|
|
'_', '_', '\n', '_', '\n', '>', '.', '.',
|
|
|
|
'[', ']', '0', '1', '2', '3', '4', '5',
|
|
|
|
'6', '7', '8', '9', '.', '_', '_', '_',
|
|
|
|
' ', '!', '\"', '#', '$', '%', '&', '\'',
|
|
|
|
'(', ')', '*', '+', ',', '-', '.', '/',
|
|
|
|
'0', '1', '2', '3', '4', '5', '6', '7',
|
|
|
|
'8', '9', ':', ';', '<', '=', '>', '?',
|
|
|
|
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
|
|
|
|
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
|
|
|
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
|
|
|
|
'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
|
|
|
|
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
|
|
|
|
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
|
|
|
|
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
|
|
|
|
'x', 'y', 'z', '{', '|', '}', '~', '_',
|
|
|
|
'_', '_', '_', '_', '_', '.', '_', '_',
|
|
|
|
'_', '_', '_', '_', '_', '>', '.', '.',
|
|
|
|
'[', ']', '0', '1', '2', '3', '4', '5',
|
|
|
|
'6', '7', '8', '9', '.', '_', '_', '_',
|
|
|
|
' ', '!', '\"', '#', '$', '%', '&', '\'',
|
|
|
|
'(', ')', '*', '+', ',', '-', '.', '/',
|
|
|
|
'0', '1', '2', '3', '4', '5', '6', '7',
|
|
|
|
'8', '9', ':', ';', '<', '=', '>', '?',
|
|
|
|
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
|
|
|
|
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
|
|
|
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
|
|
|
|
'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
|
|
|
|
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
|
|
|
|
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
|
|
|
|
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
|
2005-09-27 04:05:32 +00:00
|
|
|
'x', 'y', 'z', '{', '|', '}', '~', '_'
|
|
|
|
};
|
|
|
|
|
2006-04-12 00:17:02 +00:00
|
|
|
// Log_Dir_Callback: called when a log_dir is changed
|
|
|
|
void Log_Dir_Callback (struct cvar_s *var, char *oldvalue)
|
|
|
|
{
|
|
|
|
char *t = var->string;
|
|
|
|
|
|
|
|
// sanity check for directory
|
|
|
|
if (strstr(t, "..") || strstr(t, ":") || *t == '/' || *t == '\\')
|
|
|
|
{
|
2007-09-23 15:28:06 +00:00
|
|
|
Con_Printf(CON_NOTICE "%s forced to default due to invalid characters.\n", var->name);
|
2006-04-12 00:17:02 +00:00
|
|
|
// recursion is avoided by assuming the default value is sane
|
|
|
|
Cvar_ForceSet(var, var->defaultstr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-27 21:24:31 +00:00
|
|
|
// Log_Name_Callback: called when a log_name is changed
|
2006-04-12 00:17:02 +00:00
|
|
|
void Log_Name_Callback (struct cvar_s *var, char *oldvalue)
|
|
|
|
{
|
|
|
|
char *t = var->string;
|
|
|
|
|
|
|
|
// sanity check for directory
|
|
|
|
if (strstr(t, "..") || strstr(t, ":") || strstr(t, "/") || strstr(t, "\\"))
|
|
|
|
{
|
2007-09-23 15:28:06 +00:00
|
|
|
Con_Printf(CON_NOTICE "%s forced to default due to invalid characters.\n", var->name);
|
2006-04-12 00:17:02 +00:00
|
|
|
// recursion is avoided by assuming the default value is sane
|
|
|
|
Cvar_ForceSet(var, var->defaultstr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-27 04:05:32 +00:00
|
|
|
// Con_Log: log string to console log
|
2007-07-27 21:24:31 +00:00
|
|
|
void Log_String (logtype_t lognum, char *s)
|
2005-09-27 04:05:32 +00:00
|
|
|
{
|
2007-07-27 21:24:31 +00:00
|
|
|
vfsfile_t *fi;
|
2005-09-27 04:05:32 +00:00
|
|
|
char *d; // directory
|
|
|
|
char *f; // filename
|
|
|
|
char *t;
|
|
|
|
char logbuf[1024];
|
|
|
|
int i;
|
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
|
|
|
char fname[MAX_QPATH];
|
2005-09-27 04:05:32 +00:00
|
|
|
|
2007-07-27 21:24:31 +00:00
|
|
|
if (!log_enable[lognum].value)
|
2005-09-27 04:05:32 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// get directory/filename
|
|
|
|
d = gamedirfile;
|
|
|
|
if (log_dir.string[0])
|
|
|
|
d = log_dir.string;
|
2006-03-04 20:43:48 +00:00
|
|
|
|
2007-07-27 21:24:31 +00:00
|
|
|
f = NULL;
|
|
|
|
switch(lognum)
|
|
|
|
{
|
|
|
|
case LOG_CONSOLE:
|
|
|
|
f = "qconsole";
|
|
|
|
break;
|
|
|
|
case LOG_PLAYER:
|
|
|
|
f = "players";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (log_name[lognum].string[0])
|
|
|
|
f = log_name[lognum].string;
|
|
|
|
|
|
|
|
if (!f)
|
|
|
|
return;
|
2005-09-27 04:05:32 +00:00
|
|
|
|
|
|
|
// readable translation and Q3 code removal, use t for final string to write
|
|
|
|
t = logbuf;
|
|
|
|
// max debuglog buf is 1024
|
|
|
|
for (i = 0; i < 1023; i++, s++)
|
|
|
|
{
|
|
|
|
if (*s == 0)
|
|
|
|
break;
|
|
|
|
else if (((int)(log_readable.value) & 2) && *s == '^')
|
|
|
|
{
|
|
|
|
// log_readable 2 removes Q3 codes as well
|
2006-01-11 07:23:31 +00:00
|
|
|
char c = s[1];
|
2005-09-27 04:05:32 +00:00
|
|
|
|
2006-01-11 07:23:31 +00:00
|
|
|
if ((c >= '0' && c <= '9') || c == 'a' || c == 'b' || c == 'h' || c == 's' || c == 'r')
|
2005-09-27 04:05:32 +00:00
|
|
|
{
|
|
|
|
i--;
|
|
|
|
s++;
|
|
|
|
}
|
2006-01-11 07:23:31 +00:00
|
|
|
else if (c == '&')
|
|
|
|
{
|
|
|
|
if (isextendedcode(s[2]) && isextendedcode(s[3]))
|
|
|
|
{
|
|
|
|
i--;
|
|
|
|
s += 3;
|
|
|
|
}
|
|
|
|
}
|
2005-09-27 04:05:32 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
*t = '^';
|
|
|
|
t++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (log_dosformat.value && *s == '\n')
|
|
|
|
{
|
|
|
|
// convert \n to \r\n
|
|
|
|
*t = '\r';
|
|
|
|
t++;
|
|
|
|
i++;
|
|
|
|
if (i < 1023)
|
|
|
|
{
|
|
|
|
*t = '\n';
|
|
|
|
t++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// use readable table to convert quake chars to reabable text
|
|
|
|
if ((int)(log_readable.value) & 1)
|
|
|
|
*t = readable[(unsigned char)(*s)]; // translate
|
|
|
|
else
|
|
|
|
*t = *s; // copy
|
|
|
|
t++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*t = 0;
|
|
|
|
|
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
|
|
|
Q_snprintfz(fname, sizeof(fname), "%s/%s.log",d,f);
|
2005-09-27 04:05:32 +00:00
|
|
|
|
|
|
|
// file rotation
|
2006-03-04 20:43:48 +00:00
|
|
|
if (log_rotate_size.value >= 4096 && log_rotate_files.value >= 1)
|
2005-09-27 04:05:32 +00:00
|
|
|
{
|
|
|
|
int x;
|
2005-12-21 03:07:33 +00:00
|
|
|
vfsfile_t *fi;
|
2005-09-27 04:05:32 +00:00
|
|
|
|
|
|
|
// check file size, use x as temp
|
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
|
|
|
if ((fi = FS_OpenVFS(fname, "rb", FS_ROOT)))
|
2005-09-27 04:05:32 +00:00
|
|
|
{
|
2005-12-21 03:07:33 +00:00
|
|
|
x = VFS_GETLEN(fi);
|
|
|
|
VFS_CLOSE(fi);
|
2005-12-21 07:00:33 +00:00
|
|
|
x += i; // add string size to file size to never go over
|
2005-09-27 04:05:32 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
x = 0;
|
|
|
|
|
|
|
|
if (x > (int)log_rotate_size.value)
|
|
|
|
{
|
|
|
|
char newf[MAX_OSPATH];
|
|
|
|
char oldf[MAX_OSPATH];
|
|
|
|
|
|
|
|
i = log_rotate_files.value;
|
2006-03-04 20:43:48 +00:00
|
|
|
|
2005-09-27 04:05:32 +00:00
|
|
|
// unlink file at the top of the chain
|
2006-03-06 01:41:09 +00:00
|
|
|
snprintf(oldf, sizeof(oldf)-1, "%s.%i", f, i);
|
2008-12-23 02:55:20 +00:00
|
|
|
FS_Remove(oldf, FS_ROOT);
|
2005-09-27 04:05:32 +00:00
|
|
|
|
|
|
|
// rename files through chain
|
|
|
|
for (x = i-1; x > 0; x--)
|
|
|
|
{
|
|
|
|
strcpy(newf, oldf);
|
2006-03-06 01:41:09 +00:00
|
|
|
snprintf(oldf, sizeof(oldf)-1, "%s.%i", f, x);
|
2005-09-27 04:05:32 +00:00
|
|
|
|
|
|
|
// check if file exists, otherwise skip
|
2008-12-23 02:55:20 +00:00
|
|
|
if ((fi = FS_OpenVFS(oldf, "rb", FS_ROOT)))
|
2005-12-21 03:07:33 +00:00
|
|
|
VFS_CLOSE(fi);
|
2005-09-27 04:05:32 +00:00
|
|
|
else
|
|
|
|
continue; // skip nonexistant files
|
|
|
|
|
2012-04-24 07:59:11 +00:00
|
|
|
if (!FS_Rename(oldf, newf, FS_ROOT))
|
2005-09-27 04:05:32 +00:00
|
|
|
{
|
|
|
|
// rename failed, disable log and bug out
|
2007-07-27 21:24:31 +00:00
|
|
|
Cvar_ForceSet(&log_enable[lognum], "0");
|
2005-09-27 04:05:32 +00:00
|
|
|
Con_Printf("Unable to rotate log files. Logging disabled.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: option to compress file somewhere in here?
|
|
|
|
// rename our base file, which better exist...
|
2012-04-24 07:59:11 +00:00
|
|
|
if (!FS_Rename(f, oldf, FS_ROOT))
|
2005-09-27 04:05:32 +00:00
|
|
|
{
|
|
|
|
// rename failed, disable log and bug out
|
2007-07-27 21:24:31 +00:00
|
|
|
Cvar_ForceSet(&log_enable[lognum], "0");
|
2005-09-27 04:05:32 +00:00
|
|
|
Con_Printf("Unable to rename base log file. Logging disabled.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-23 02:55:20 +00:00
|
|
|
FS_CreatePath(f, FS_ROOT);
|
|
|
|
if ((fi = FS_OpenVFS(f, "ab", FS_ROOT)))
|
2007-07-27 21:24:31 +00:00
|
|
|
{
|
|
|
|
VFS_WRITE(fi, logbuf, strlen(logbuf));
|
|
|
|
VFS_CLOSE(fi);
|
|
|
|
}
|
|
|
|
else
|
2005-12-05 16:47:29 +00:00
|
|
|
{
|
|
|
|
// write failed, bug out
|
2007-07-27 21:24:31 +00:00
|
|
|
Cvar_ForceSet(&log_enable[lognum], "0");
|
2005-12-05 16:47:29 +00:00
|
|
|
Con_Printf("Unable to write to log file. Logging disabled.\n");
|
|
|
|
return;
|
|
|
|
}
|
2005-09-27 04:05:32 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 21:24:31 +00:00
|
|
|
void Con_Log (char *s)
|
|
|
|
{
|
|
|
|
Log_String(LOG_CONSOLE, s);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-07 14:41:23 +00:00
|
|
|
#ifndef CLIENTONLY
|
2007-07-27 21:24:31 +00:00
|
|
|
//still to add stuff at:
|
|
|
|
//connects
|
|
|
|
//disconnects
|
|
|
|
//kicked
|
|
|
|
void SV_LogPlayer(client_t *cl, char *msg)
|
|
|
|
{
|
|
|
|
char line[2048];
|
2008-06-08 14:37:57 +00:00
|
|
|
char remote_adr[MAX_ADR_SIZE];
|
|
|
|
char realip_adr[MAX_ADR_SIZE];
|
|
|
|
|
2008-12-06 02:08:57 +00:00
|
|
|
if (cl->protocol == SCP_BAD)
|
|
|
|
return; //don't log botclients
|
|
|
|
|
2007-07-27 21:24:31 +00:00
|
|
|
snprintf(line, sizeof(line),
|
2011-05-15 13:23:13 +00:00
|
|
|
"%s\\%s\\%i\\%s\\%s\\%i%s\n",
|
|
|
|
msg, cl->name, cl->userid,
|
2013-05-03 04:28:08 +00:00
|
|
|
NET_BaseAdrToString(remote_adr, sizeof(remote_adr), &cl->netchan.remote_address), (cl->realip_status > 0 ? NET_BaseAdrToString(realip_adr, sizeof(realip_adr), &cl->realip) : "??"),
|
2007-07-27 21:24:31 +00:00
|
|
|
cl->netchan.remote_address.port, cl->userinfo);
|
|
|
|
|
|
|
|
Log_String(LOG_PLAYER, line);
|
|
|
|
}
|
2007-08-07 14:41:23 +00:00
|
|
|
#endif
|
2007-07-27 21:24:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Log_Logfile_f (void)
|
|
|
|
{
|
|
|
|
extern char gamedirfile[];
|
|
|
|
|
|
|
|
if (log_enable[LOG_CONSOLE].value)
|
|
|
|
{
|
|
|
|
Cvar_SetValue(&log_enable[LOG_CONSOLE], 0);
|
|
|
|
Con_Printf("Logging disabled.\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char *d, *f;
|
|
|
|
|
|
|
|
d = gamedirfile;
|
|
|
|
if (log_dir.string[0])
|
|
|
|
d = log_dir.string;
|
|
|
|
|
|
|
|
f = "qconsole";
|
|
|
|
if (log_name[LOG_CONSOLE].string[0])
|
|
|
|
f = log_name[LOG_CONSOLE].string;
|
|
|
|
|
2011-05-15 13:23:13 +00:00
|
|
|
Con_Printf("%s", va("Logging to %s/%s.log.\n", d, f));
|
2007-07-27 21:24:31 +00:00
|
|
|
Cvar_SetValue(&log_enable[LOG_CONSOLE], 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
void SV_Fraglogfile_f (void)
|
|
|
|
{
|
|
|
|
char name[MAX_OSPATH];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (sv_fraglogfile)
|
|
|
|
{
|
|
|
|
Con_TPrintf (STL_FLOGGINGOFF);
|
|
|
|
VFS_CLOSE (sv_fraglogfile);
|
|
|
|
sv_fraglogfile = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// find an unused name
|
|
|
|
for (i=0 ; i<1000 ; i++)
|
|
|
|
{
|
|
|
|
sprintf (name, "frag_%i.log", i);
|
|
|
|
sv_fraglogfile = FS_OpenVFS(name, "rb", FS_GAME);
|
|
|
|
if (!sv_fraglogfile)
|
|
|
|
{ // can't read it, so create this one
|
|
|
|
sv_fraglogfile = FS_OpenVFS (name, "wb", FS_GAME);
|
|
|
|
if (!sv_fraglogfile)
|
|
|
|
i=1000; // give error
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
VFS_CLOSE (sv_fraglogfile);
|
|
|
|
}
|
|
|
|
if (i==1000)
|
|
|
|
{
|
|
|
|
Con_TPrintf (STL_FLOGGINGFAILED);
|
|
|
|
sv_fraglogfile = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Con_TPrintf (STL_FLOGGINGTO, name);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2005-09-27 04:05:32 +00:00
|
|
|
void Log_Init(void)
|
|
|
|
{
|
2007-07-27 21:24:31 +00:00
|
|
|
int i;
|
2005-09-27 04:05:32 +00:00
|
|
|
// register cvars
|
2007-07-27 21:24:31 +00:00
|
|
|
for (i = 0; i < LOG_TYPES; i++)
|
|
|
|
{
|
|
|
|
Cvar_Register (&log_enable[i], CONLOGGROUP);
|
|
|
|
Cvar_Register (&log_name[i], CONLOGGROUP);
|
|
|
|
}
|
2005-09-27 04:05:32 +00:00
|
|
|
Cvar_Register (&log_dir, CONLOGGROUP);
|
|
|
|
Cvar_Register (&log_readable, CONLOGGROUP);
|
|
|
|
Cvar_Register (&log_developer, CONLOGGROUP);
|
|
|
|
Cvar_Register (&log_rotate_size, CONLOGGROUP);
|
|
|
|
Cvar_Register (&log_rotate_files, CONLOGGROUP);
|
|
|
|
Cvar_Register (&log_dosformat, CONLOGGROUP);
|
|
|
|
|
2007-07-27 21:24:31 +00:00
|
|
|
Cmd_AddCommand("logfile", Log_Logfile_f);
|
|
|
|
|
2005-09-27 04:05:32 +00:00
|
|
|
// cmd line options, debug options
|
|
|
|
#ifdef CRAZYDEBUGGING
|
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
|
|
|
Cvar_ForceSet(&log_enable[LOG_CONSOLE], "1");
|
2005-09-27 04:05:32 +00:00
|
|
|
TRACE(("dbg: Con_Init: log_enable forced\n"));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (COM_CheckParm("-condebug"))
|
2007-07-27 21:24:31 +00:00
|
|
|
Cvar_ForceSet(&log_enable[LOG_CONSOLE], "1");
|
2006-03-04 20:43:48 +00:00
|
|
|
}
|