Xonotic
gamelog.qc
Go to the documentation of this file.
1 #include "gamelog.qh"
2 
3 #include <server/main.qh>
4 
5 string GameLog_ProcessIP(string s)
6 {
8  return s;
9  return strreplace(":", "_", s);
10 }
11 
12 void GameLogEcho(string s)
13 {
15  {
16  if (!logfile_open)
17  {
18  logfile_open = true;
19  int matches = autocvar_sv_eventlog_files_counter + 1;
20  cvar_set("sv_eventlog_files_counter", itos(matches));
21  string fn = ftos(matches);
22  if (strlen(fn) < 8)
23  fn = strcat(substring("00000000", 0, 8 - strlen(fn)), fn);
25  logfile = fopen(fn, FILE_APPEND);
26  fputs(logfile, ":logversion:3\n");
27  }
28  if (logfile >= 0)
29  {
31  fputs(logfile, strcat(":time:", strftime(true, "%Y-%m-%d %H:%M:%S", "\n", s, "\n")));
32  else
33  fputs(logfile, strcat(s, "\n"));
34  }
35  }
37  {
38  dedicated_print(strcat(s, "\n"));
39  }
40 }
41 
43 {
44  logfile_open = false;
45  // will be opened later
46 }
47 
49 {
50  if (logfile_open && logfile >= 0)
51  {
52  fclose(logfile);
53  logfile = -1;
54  }
55 }
bool autocvar_sv_eventlog_files_timestamps
Definition: gamelog.qh:9
void dedicated_print(string input)
print(), but only print if the server is not local
Definition: main.qc:205
void GameLogClose()
Definition: gamelog.qc:48
bool autocvar_sv_eventlog_files
Definition: gamelog.qh:5
const float FILE_APPEND
Definition: csprogsdefs.qc:232
float logfile
Definition: gamelog.qh:13
#define itos(i)
Definition: int.qh:6
bool autocvar_sv_eventlog_console
Definition: gamelog.qh:4
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
bool logfile_open
Definition: gamelog.qh:12
void GameLogEcho(string s)
Definition: gamelog.qc:12
void GameLogInit()
Definition: gamelog.qc:42
string GameLog_ProcessIP(string s)
Definition: gamelog.qc:5
string autocvar_sv_eventlog_files_namesuffix
Definition: gamelog.qh:8
bool autocvar_sv_eventlog_ipv6_delimiter
Definition: gamelog.qh:10
int autocvar_sv_eventlog_files_counter
Definition: gamelog.qh:6
string autocvar_sv_eventlog_files_nameprefix
Definition: gamelog.qh:7