]> git.pond.sub.org Git - empserver/commitdiff
New journal event output
authorMarkus Armbruster <armbru@pond.sub.org>
Wed, 30 Jul 2008 00:38:48 +0000 (20:38 -0400)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 10 Mar 2009 14:27:51 +0000 (15:27 +0100)
To enable, set econfig key keep_journal to at least 2.  Output events
are *not* flushed to disk immediately.

Put it in Hvy Metal II now to gather real data for future testing of a
journal replay tool.

include/journal.h
src/lib/subs/journal.c
src/lib/subs/pr.c

index d0cbacdc0134fd648668db02d937100076bba467..b52e14b1ffbde781e3297418e33f262837f95a41 100644 (file)
 #ifndef JOURNAL_H
 #define JOURNAL_H
 
+struct player;                 /* FIXME temporary hack */
+
 int journal_startup(void);
 void journal_shutdown(void);
 int journal_reopen(void);
 void journal_login(void);
 void journal_logout(void);
 void journal_prng(unsigned);
+void journal_output(struct player *, int, char *);
 void journal_input(char *);
 void journal_command(char *);
 void journal_update(int);
index 90c34a62a01f375b6d8541466dd2ae36b368bd7e..e0ec176261ef7d88af598021e4263b6e49c2a4c8 100644 (file)
@@ -46,6 +46,7 @@
  *     logout CNUM
  *     command NAME
  *     input INPUT
+ *     output THREAD ID OUTPUT
  *     update ETU
  */
 
@@ -99,7 +100,8 @@ journal_entry(char *fmt, ...)
                fprintf(journal, "\\%03o", *p);
        }
        fputs("\n", journal);
-       fflush(journal);
+       if (fmt[0] != 'o')      /* FIXME disgusting hack */
+           fflush(journal);
        if (ferror(journal)) {
            logerror("Error writing journal (%s)", strerror(errno));
            clearerr(journal);
@@ -168,6 +170,17 @@ journal_logout(void)
     journal_entry("logout %d", player->cnum);
 }
 
+void
+journal_output(struct player *pl, int id, char *output)
+{
+    if (keep_journal < 2)
+       return;
+    if (pl && pl->state == PS_PLAYING)
+       journal_entry("output %d %d %s", pl->cnum, id, output);
+    else
+       journal_entry("output %p %d %s", pl, id, output);
+}
+
 void
 journal_input(char *input)
 {
index 3ba199ee9b7ed78e3a501f9a72a846025977689c..55fb0c13b925504790df479666d939019a87f47b 100644 (file)
@@ -56,6 +56,7 @@
 #include "com.h"
 #include "empio.h"
 #include "file.h"
+#include "journal.h"
 #include "misc.h"
 #include "nat.h"
 #include "player.h"
@@ -245,6 +246,7 @@ pr_player(struct player *pl, int id, char *buf)
            bp += len;
        }
     }
+    journal_output(pl, id, buf);
 }
 
 /*
@@ -299,6 +301,7 @@ upr_player(struct player *pl, int id, char *buf)
            io_puts(pl->iop, printbuf);
        }
     }
+    journal_output(pl, id, buf);
 }
 
 /*