]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/log.cpp
updated the Change log w/ new additions
[irc/gameservirc.git] / gameserv / log.cpp
index d45d05be8bb76728bf3275aecfff2189e42206ca..d7c8ee58aecc654696dac5e30d3d5483e2a3793a 100644 (file)
@@ -8,61 +8,63 @@ using namespace std;
 
 void log(const char *fmt, ...)
 {
-    if (fmt[0] == '\0')
-        return;
-
-    ofstream outfile;
-    char *ts, *output;
-    const char *t = fmt;
-
-    ts = new char[64];
-    output = new char[4096];
-
-    outfile.open("gameserv.log", ios::out | ios::app);
-
-    if (outfile.fail())
-    {
-       cerr << "Error opening gameserv.log" << endl;
+  if (fmt[0] == '\0')
        return;
-    }
-
-    struct tm *tm;
-    time_t ti;
-    time(&ti);
-    tm = localtime(&ti);
-    strftime(ts, 64, "%m/%d/%Y %H:%M:%S", tm);
-
-    sprintf(output, "[%s]: ", ts);
-
-    va_list args;
-    va_start(args, fmt);
-
-    for (; *t; t++)
+  
+  ofstream outfile;
+  char *ts, *output;
+  const char *t = fmt;
+  
+  ts = new char[64];
+  output = new char[4096];
+  
+  outfile.open("gameserv.log", ios::out | ios::app);
+  
+  if (outfile.fail())
+       {
+         delete []ts;
+         delete []output;
+         cerr << "Error opening gameserv.log" << endl;
+         return;
+       }
+  
+  struct tm *tm;
+  time_t ti;
+  time(&ti);
+  tm = localtime(&ti);
+  strftime(ts, 64, "%m/%d/%Y %H:%M:%S", tm);
+  
+  sprintf(output, "[%s]: ", ts);
+  
+  va_list args;
+  va_start(args, fmt);
+  
+  for (; *t; t++)
     {
-        if (*t == '%')
+         if (*t == '%')
         {
-            switch(*++t) {
-                case 'd': sprintf(output, "%s%d", output, va_arg(args, int)); break;
-                case 's': sprintf(output, "%s%s", output, va_arg(args, char *)); break;
-                case 'S': sprintf(output, "%s%s", output, s_GameServ); break;
-               case 'c': sprintf(output, "%s%c", output, va_arg(args, int)); break;
-                case 'l':
-                   if (*++t == 'd')
-                          sprintf(output, "%s%ld", output, va_arg(args, long int)); break;
-            }
+                 switch(*++t) {
+                 case 'd': sprintf(output, "%s%d", output, va_arg(args, int)); break;
+                 case 's': sprintf(output, "%s%s", output, va_arg(args, char *)); break;
+                 case 'S': sprintf(output, "%s%s", output, s_GameServ); break;
+                 case 'c': sprintf(output, "%s%c", output, va_arg(args, int)); break;
+                 case 'l':
+                       if (*++t == 'd')
+                         sprintf(output, "%s%ld", output, va_arg(args, long int)); break;
+                 }
         }
-        else
+         else
         {
-            sprintf(output, "%s%c", output, *t);
+                 sprintf(output, "%s%c", output, *t);
         }
-
+         
     }
-
-    outfile << output << endl;
-
-    outfile.close();
-    va_end(args);
-
-    delete [] ts;
-    delete [] output;
+  
+  outfile << output << endl;
+  
+  outfile.close();
+  va_end(args);
+  
+  delete [] ts;
+  delete [] output;
 }