]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/journal.c
journal: Don't immediately flush output events to disk
[empserver] / src / lib / subs / journal.c
index ea795df581913bd7773eb78e94b880495a7c9816..f98d27311299539ebed75a2e18a4246acf5cea4f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2011, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2021, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                Ken Stevens, Steve McClure, Markus Armbruster
  *
  *  Empire is free software: you can redistribute it and/or modify
@@ -27,7 +27,7 @@
  *  journal.c: Log a journal of events to a file
  *
  *  Known contributors to this file:
- *     Markus Armbruster, 2004-2011
+ *     Markus Armbruster, 2004-2012
  *     Ron Koenderink, 2008
  */
 
@@ -82,12 +82,14 @@ static void
 journal_entry_vstart(char *fmt, va_list ap)
 {
     time_t now;
+    empth_t *self;
 
     if (!journal)
        return;
     time(&now);
+    self = empth_self();
     fprintf(journal, "%.24s %10.10s ",
-           ctime(&now), empth_name(empth_self()));
+           ctime(&now), self ? empth_name(self) : "Main");
     vfprintf(journal, fmt, ap);
 }
 
@@ -126,7 +128,8 @@ journal_entry_end(int newline, int flush)
     if (!newline)
        fputc('\\', journal);
     fputc('\n', journal);
-    fflush(journal);
+    if (flush)
+       fflush(journal);
     if (ferror(journal)) {
        logerror("Error writing journal (%s)", strerror(errno));
        clearerr(journal);
@@ -189,7 +192,7 @@ journal_reopen(void)
 void
 journal_prng(unsigned seed)
 {
-    journal_entry("prng BSD %d", seed);
+    journal_entry("prng MT19937 %u", seed);
 }
 
 void