]> granicus.if.org Git - nethack/commitdiff
the panic log
authorcohrs <cohrs>
Sun, 2 Jun 2002 18:49:18 +0000 (18:49 +0000)
committercohrs <cohrs>
Sun, 2 Jun 2002 18:49:18 +0000 (18:49 +0000)
Add an optional paniclog file, controlled by a new PANICLOG macro that can
be used to log all panic and impossible messages.  Helpful when people
forget to send, or didn't see, the message.

doc/fixes34.1
include/config.h
include/extern.h
src/end.c
src/files.c
src/pline.c

index 05e86fdf8d17dca4f0d27b27b1ec776275aff60d..954cafce73dbd40b0515946b98912ae2ed93e2a1 100644 (file)
@@ -149,3 +149,4 @@ showrace option
 travel option
 mouse_support wincap option
 debug mode: #panic routine to test panic() and panic save file generation
+a new PANICLOG optional file to log the reason for panic and impossible messages
index fddb25795d1f03e098f061df7087565c82f20973..51268e619144948226279569d261862876eae050 100644 (file)
 
 /*
  * Section 2:  Some global parameters and filenames.
- *             Commenting out WIZARD, LOGFILE, or NEWS removes that feature
- *             from the game; otherwise set the appropriate wizard name.
- *             LOGFILE and NEWS refer to files in the playground.
+ *             Commenting out WIZARD, LOGFILE, NEWS or PANICLOG removes that
+ *             feature from the game; otherwise set the appropriate wizard
+ *             name.  LOGFILE, NEWS and PANICLOG refer to files in the
+ *             playground.
  */
 
 #ifndef WIZARD         /* allow for compile-time or Makefile changes */
 
 #define LOGFILE "logfile"      /* larger file for debugging purposes */
 #define NEWS "news"            /* the file containing the latest hack news */
+#define PANICLOG "paniclog"    /* log of panic and impossible events */
 
 /*
  *     If COMPRESS is defined, it should contain the full path name of your
index 3ea9381bc3154a19bcd9b33f8a406a38f4d86215..1a0cfa86b7aca37478b237c2a45ad341a4c30a99 100644 (file)
@@ -638,6 +638,7 @@ E void FDECL(check_recordfile, (const char *));
 #if defined(WIZARD)
 E void NDECL(read_wizkit);
 #endif
+E void FDECL(paniclog, (const char *, const char *));
 
 /* ### fountain.c ### */
 
index 7cac2cbf4871ed1777cae5b05f21aaa0d52e46b8..d3b36782a12dba1a18d1426759ee38c5dc29a578 100644 (file)
--- a/src/end.c
+++ b/src/end.c
@@ -294,6 +294,7 @@ panic VA_DECL(const char *, str)
            char buf[BUFSZ];
            Vsprintf(buf,str,VA_ARGS);
            raw_print(buf);
+           paniclog("panic", buf);
        }
 #if defined(WIZARD) && (defined(UNIX) || defined(VMS) || defined(LATTICE) || defined(WIN32))
        if (wizard)
index c2f7bd560e5562d69c2223875f461ebdfd44318a..6813c250b1ae4cad92e5405484532b0524708100 100644 (file)
@@ -1782,4 +1782,26 @@ const char *dir;
 
 /* ----------  END SCOREBOARD CREATION ----------- */
 
+/* ----------  BEGIN PANIC/IMPOSSIBLE LOG ----------- */
+
+/*ARGSUSED*/
+void
+paniclog(why, s)
+const char* why;
+const char* s;
+{
+#ifdef PANICLOG
+       FILE *lfile;
+
+       lfile = fopen_datafile(PANICLOG, "a", TRUE);
+       if (lfile) {
+           (void) fprintf(lfile, "%08ld: %s %s\n",
+                          yyyymmdd((time_t)0L), why, s);
+           (void) fclose(lfile);
+       }
+#endif /* PANICLOG */
+}
+
+/* ----------  END PANIC/IMPOSSIBLE LOG ----------- */
+
 /*files.c*/
index 08a6d1958da04d00fb8e44f2d7b6da4da23fe1cf..72766f9ae65a85c11f93eb032969c1d9c8f00af3 100644 (file)
@@ -248,6 +248,11 @@ void
 impossible VA_DECL(const char *, s)
        VA_START(s);
        VA_INIT(s, const char *);
+       {
+           char pbuf[BUFSZ];
+           Vsprintf(pbuf,s,VA_ARGS);
+           paniclog("impossible", s);
+       }
        vpline(s,VA_ARGS);
        pline("Program in disorder - perhaps you'd better #quit.");
        VA_END();