Author: remi
Date: 2008-06-23 15:23:11 +0200 (Mon, 23 Jun 2008)
New Revision: 1249

Modified:
   software_suite_v2/middleware/tuxdriver/trunk/src/log.c
Log:
* changed the logger. Now the file is opened for write a message and closed 
just after.

Modified: software_suite_v2/middleware/tuxdriver/trunk/src/log.c
===================================================================
--- software_suite_v2/middleware/tuxdriver/trunk/src/log.c      2008-06-23 
13:13:51 UTC (rev 1248)
+++ software_suite_v2/middleware/tuxdriver/trunk/src/log.c      2008-06-23 
13:23:11 UTC (rev 1249)
@@ -33,7 +33,7 @@
 #endif
 
 /** All logged messages are prefixed with this text */
-#define LOG_PREFIX  "tux_driver"
+#define LOG_PREFIX  "libtuxdriver"
 
 /** Current logging level */
 static log_level_t current_level = LOG_LEVEL_INFO;
@@ -80,6 +80,8 @@
         {
             return false;
         }
+        fclose(log_file);
+        log_file = NULL;
         break;
 
     case LOG_TARGET_SHELL:
@@ -106,8 +108,6 @@
     switch (log_target)
     {
     case LOG_TARGET_TUX:
-        fclose(log_file);
-        log_file = NULL;
         break;
 
     case LOG_TARGET_SHELL:
@@ -118,6 +118,22 @@
 }
 
 /**
+ *
+ */
+static void
+write_log_text(char *text)
+{
+    log_file = fopen(LOG_FILE, "a");
+    if (log_file == NULL)
+    {
+        return;
+    }
+    fprintf(log_file, "%s\n", text);
+    fclose(log_file);
+    log_file = NULL;
+}
+
+/**
  * Set the logging level.
  *
  * /param[in] new_level  New logging level
@@ -217,17 +233,17 @@
     switch (log_target)
     {
     case LOG_TARGET_TUX:
-        fprintf(log_file, "%s\n", text);
+        write_log_text(text);
         break;
 
     case LOG_TARGET_SHELL:
         if (at_level == LOG_LEVEL_WARNING || at_level == LOG_LEVEL_ERROR)
         {
-            fprintf(stderr, "tux_driver: %s\n", text);
+            fprintf(stderr, "%s: %s\n", LOG_PREFIX, text);
         }
         else
         {
-            fprintf(stdout, "tux_driver: %s\n", text);
+            fprintf(stdout, "%s: %s\n", LOG_PREFIX, text);
         }
         break;
     }


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to