--- deliantra/server/common/init.C 2007/11/10 22:41:59 1.42 +++ deliantra/server/common/init.C 2008/04/15 03:16:02 1.44 @@ -1,7 +1,7 @@ /* * This file is part of Deliantra, the Roguelike Realtime MMORPG. * - * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team + * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team * Copyright (©) 1992,2007 Frank Tore Johansen * @@ -188,14 +188,19 @@ init_globals (void) { if (settings.logfilename[0] == 0) - logfile = stderr; - else if ((logfile = fopen (settings.logfilename, "a")) == NULL) + set_logfd (-1); + else { - fprintf (stderr, "Unable to open %s as the logfile - will use stderr instead\n", settings.logfilename); - logfile = stderr; + int logfd = open (settings.logfilename, O_CREAT|O_WRONLY|O_APPEND, 0666); + + if (logfd >= 0) + set_logfd (logfd); + else + { + set_logfd (-1); + LOG (llevError, "Unable to open %s as the logfile - will use stderr instead", settings.logfilename); + } } - else - setvbuf (logfile, NULL, _IOLBF, 0); } void