]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/log.c
this never ends...
[irc/evilnet/x3.git] / src / log.c
index f7457006c80dc00115a25d1c4eaac09e71ee60e1..d019f0d5f7449327dffaeb3d4c946f31d5823a7a 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -1,7 +1,7 @@
 /* log.c - Diagnostic and error logging
  * Copyright 2000-2004 srvx Development Team
  *
- * This file is part of srvx.
+ * This file is part of x3.
  *
  * srvx is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -587,6 +587,10 @@ log_module(struct log_type *type, enum log_severity sev, const char *format, ...
         /* Special behavior before we start full operation */
         fprintf(stderr, "%s: %s\n", log_severity_names[sev], msgbuf);
     }
+    if (sev == LOG_FATAL) {
+        assert(0 && "fatal message logged");
+        _exit(1);
+    }
 }
 
 /* audit log searching */
@@ -719,9 +723,13 @@ log_entry_search(struct logSearch *discrim, entry_search_func esf, void *data)
     unsigned int matched = 0;
 
     if (discrim->type) {
+        static volatile struct logEntry *last;
         struct logEntry *entry;
 
-        for (entry = discrim->type->log_oldest; entry; entry = entry->next) {
+        for (entry = discrim->type->log_oldest, last = NULL;
+             entry;
+             last = entry, entry = entry->next) {
+            verify(entry);
             if (entry_match(discrim, entry)) {
                 esf(entry, data);
                 if (++matched >= discrim->limit)
@@ -993,3 +1001,31 @@ log_init(void)
     message_register_table(msgtab);
     log_inited = 1;
 }
+
+void SyncLog(char *fmt,...)
+{
+  va_list args;
+  char buff[MAXLEN*4];
+  char *tmp;
+  FILE *LogFile;
+
+  va_start(args, fmt);
+  vsnprintf(buff, MAXLEN, fmt, args);
+  buff[MAXLEN - 1] = '\0';
+  va_end(args);
+
+  for (tmp = buff; *tmp; tmp++)
+  {
+    if ((*tmp == '\n') || (*tmp == '\r'))
+      *tmp = '\0';
+    else if (*tmp == '\001')
+      *tmp = ' ';
+  }
+
+  if((LogFile = fopen("sync.log", "a")))
+  {
+    fprintf(LogFile, "%s: %s\n", time2str(time(NULL)), buff);
+    fclose(LogFile);
+  }
+
+}