Re: There was a problem loading your objects from disk.

From: Mike Stilson (mike@velgarian.sytes.net)
Date: 02/23/02


With the plethora of people who can't seem to wrap their minds around
grep'ing a file for where there's an error, here's an idea that should
stop these problems from showing up all the time...
>
If you get some errors, just recompile the mud with -DDEBUG_LOG in the
makefile; added to MYFLAGS at line 12 of the Makefile after -Wall
(so it would be like this:
MYFLAGS = -Wall -DDEBUG_LOG

It'll show you the file, function, and even the line number of every
single time log() is called.

For how to apply it, I refer you to section 2.7 of the FAQ that came
with the source.

Ignore the last patch, it forgot to update the __attribute__ definition
in the prototype for basic_mud_log().

Untested patch vs stock bpl20
---- 8< cut here >8 ----

diff -Nupr src/utils.c src.new/utils.c
--- src/utils.c Sat Feb 23 10:08:31 2002
+++ src.new/utils.c     Sat Feb 23 10:24:07 2002
@@ -175,7 +175,11 @@ void log_death_trap(struct char_data *ch
  * New variable argument log() function.  Works the same as the old for
  * previously written code but is very nice for new code.
  */
+#ifdef DEBUG_LOG
+void basic_mud_log(const char *file, const char *function, const int line, const char *format, ...)
+#else
 void basic_mud_log(const char *format, ...)
+#endif
 {
   va_list args;
   time_t ct = time(0);
@@ -191,7 +195,11 @@ void basic_mud_log(const char *format, .

   time_s[strlen(time_s) - 1] = '\0';

+#ifdef DEBUG_LOG
+  fprintf(logfile, "%-15.15s :: %s:%d(%s) ", time_s + 4, file, line, function);
+#else
   fprintf(logfile, "%-15.15s :: ", time_s + 4);
+#endif

   va_start(args, format);
   vfprintf(logfile, format, args);
diff -Nupr src/utils.h src.new/utils.h
--- src/utils.h Sat Feb 23 10:08:30 2002
+++ src.new/utils.h     Sat Feb 23 10:24:07 2002
@@ -14,13 +14,21 @@
 extern struct weather_data weather_info;
 extern FILE *logfile;

-#define log                    basic_mud_log
+#ifdef DEBUG_LOG
+#define log(x, args...)                        basic_mud_log(__FILE__, __FUNCTION__, __LINE__, fmt, args)
+#else
+#define log    basic_mud_log
+#endif

 /* public functions in utils.c */
 char   *str_dup(const char *source);
 int    str_cmp(const char *arg1, const char *arg2);
 int    strn_cmp(const char *arg1, const char *arg2, int n);
+#ifdef DEBUG_LOG
+void   basic_mud_log(const char *, const char *, int, const char *format, ...) __attribute__ ((format (printf, 4, 5)));
+#else
 void   basic_mud_log(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
+#endif
 int    touch(const char *path);
 void   mudlog(const char *str, int type, int level, int file);
 void   log_death_trap(struct char_data *ch);

-------- end patch -----

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT