From 80361c9a3b7fde14bbc094cc1dd241b52e33d9bc Mon Sep 17 00:00:00 2001 From: Fate Date: Fri, 11 Sep 2009 05:38:13 +0000 Subject: Added mapserver config option log_file to specify gzipped player action log file --- src/map/map.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/map/map.c') diff --git a/src/map/map.c b/src/map/map.c index cf50dfc..98be77b 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -1656,6 +1656,28 @@ int map_delmap(char *mapname) { extern char *gm_logfile_name; +FILE *map_logfile = NULL; + +static void +map_pclose_map_logfile() +{ + pclose(map_logfile); +} + +static void +map_setlogfile(const char *filename) +{ + char *filename_buf = malloc(strlen (filename) + 50); + sprintf(filename_buf, "gzip -c > %s", filename); + map_logfile = popen(filename_buf, "w"); + if (!map_logfile) + perror(filename); + else + atexit(map_pclose_map_logfile); + free(filename_buf); + MAP_LOG("log-start"); +} + /*========================================== * 設定ファイルを読み込む *------------------------------------------ @@ -1725,6 +1747,8 @@ int map_config_read(char *cfgName) { strcpy(mapreg_txt, w2); } else if (strcmpi(w1, "gm_log") == 0) { gm_logfile_name = strdup(w2); + } else if (strcmpi(w1, "log_file") == 0) { + map_setlogfile(w2); } else if (strcmpi(w1, "import") == 0) { map_config_read(w2); } -- cgit v1.2.3-70-g09d2