/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2004, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
-#ifdef Rel4
#include <string.h>
-#endif /* Rel4 */
#include <time.h>
-#include "deity.h"
#include "player.h"
#include "common.h"
+#include "optlist.h"
static s_char *logfile = 0;
-s_char *
-getlogfile()
-{
- return (s_char *)logfile;
-}
-
/*
* Points logfile at datadir/"program".log
*/
void
-loginit(void)
+loginit(s_char *program)
{
- extern s_char program[];
- extern s_char *datadir;
s_char buf[1024];
#if !defined(_WIN32)
int logf;
s_char *p;
- if (logfile == 0)
- loginit();
va_start(list, format);
vsprintf(buf, format, list);
- if ((p = index(buf, '\n')) != 0)
+ if ((p = strchr(buf, '\n')) != 0)
*p = 0;
(void)time(&now);
strcpy(cbuf, ctime(&now));
- if ((p = index(cbuf, '\n')) != 0)
+ if ((p = strchr(cbuf, '\n')) != 0)
*p = 0;
(void)sprintf(buf1, "%s %s\n", cbuf, buf);
if ((logf = open(logfile, O_WRONLY | O_CREAT | O_APPEND, 0666)) < 0)
#endif
va_end(list);
}
+
+/*
+ * Log internal error MSG occured in FILE:LINE.
+ * If debugging, call abort(), else return 1.
+ */
+int
+oops(char *msg, char *file, int line)
+{
+ logerror("Oops: %s in %s:%d\n", msg, file, line);
+ if (debug) abort();
+ return 1;
+}