[Circle] [Newbie] Log crashing errors.

From: DJ Pure (pure@ozramp.net.au)
Date: 11/11/96

I'm trying to make it so that the mud logs all the info to a file, instead
of to the screen.
The ported version for win95 just printed the log command to the screen.
Information :- using vc4.0 in win95. Compiles fine (no warnings). Credit
is also given to Christopher M. Ryan whose has helped me by suggesting
these changes which I added.

Thanks to those who can help.

What i've done is this.

in utils.c

void log(char *str)
// Added the use of LOGGING stuff to a SYSLOG file.
  time_t ct;
  char *tmstr;
  /*added here*/ FILE *log;

  ct = time(0);
  tmstr = asctime(localtime(&ct));
  *(tmstr + strlen(tmstr) - 1) = '\0';
 /*added here*/ fprintf(log, "%-19.19s :: %s\n", tmstr, str);
  //  fprintf(stderr, "%-19.19s :: %s\n", tmstr, str);

Then in comm.c
extern FILE* log;

int main(int argc, char **argv)
  int port;
  char buf[512];
  int pos = 1;
  char *dir;

  port = DFLT_PORT;
  dir = DFLT_DIR;

  // Open the Log File to log all information.
  /*Added this in .. This is where I get an error (the if statement (first
*/ if ( (log = fopen("circle.log","w")) == NULL) {
	printf ("creating new log file\n");
  else {
	printf ("overwriting old file\n");

  while ((pos < argc) && (*(argv[pos]) == '-')) {
    switch (*(argv[pos] + 1)) {
    case 'd':
/*now at the end of main */
<sinp snip>
  } else {
    sprintf(buf, "Running game on port %d.", port);

  return 0;

  // Must close the file when finished.

| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |

This archive was generated by hypermail 2b30 : 12/18/00 PST