netpanzer-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netPanzer-CVS] netpanzer/src/Lib Log.cpp


From: Ivo Danihelka
Subject: [netPanzer-CVS] netpanzer/src/Lib Log.cpp
Date: Wed, 17 Sep 2003 20:41:59 -0400

CVSROOT:        /cvsroot/netpanzer
Module name:    netpanzer
Branch:         
Changes by:     Ivo Danihelka <address@hidden>  03/09/17 20:41:59

Modified files:
        src/Lib        : Log.cpp 

Log message:
        'Do it better' logger

Patches:
Index: netpanzer/src/Lib/Log.cpp
diff -u netpanzer/src/Lib/Log.cpp:1.5 netpanzer/src/Lib/Log.cpp:1.6
--- netpanzer/src/Lib/Log.cpp:1.5       Wed Sep 17 19:46:42 2003
+++ netpanzer/src/Lib/Log.cpp   Wed Sep 17 20:41:59 2003
@@ -19,6 +19,8 @@
 #include <config.h>
 
 #include <stdarg.h>
+#include <errno.h>
+#include <string.h>
 #include "Log.hpp"
 
 #ifdef DO_LOGGING
@@ -30,9 +32,18 @@
 const int Logger::LEVEL_INFO = 6;
 const int Logger::LEVEL_WARNING = 4;
 //-----------------------------------------------------------------
+/**
+ * Default log level is INFO.
+ */
 Logger::Logger()
 {
-    m_logfile = fopen("log.txt", "w");
+    static const char *LOGNAME = "log.txt";
+
+    m_logLevel = LEVEL_INFO;
+    m_logfile = fopen(LOGNAME, "w");
+    if (m_logfile == 0) {
+        fprintf(stderr, "cannot open '%s': %s\n", LOGNAME, strerror(errno));
+    }
 }
 //-----------------------------------------------------------------
 Logger::~Logger()
@@ -47,8 +58,10 @@
 {
     if (m_logLevel >= priority) {
         vfprintf(stderr, fmt, ap);
+        fprintf(stderr, "\n");
         if (m_logfile != 0) {
             vfprintf(m_logfile, fmt, ap);
+            fprintf(m_logfile, "\n");
         }
     }
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]