Log

Dependents:   oldheating gps motorhome heating

Revision:
10:cf815db8ed57
Parent:
9:d2c41855ed09
--- a/log.cpp	Wed Oct 04 10:29:22 2017 +0000
+++ b/log.cpp	Thu Oct 26 07:17:43 2017 +0000
@@ -81,23 +81,26 @@
     pPull = buffer;
     return 0;
 }
-void Log(char* snd)
+int Log(char* snd)
 {
-    for (char* ptr = snd; *ptr; ptr++) LogPush(*ptr); //Send the string to the log buffer
+    char* ptr = snd;
+    while (*ptr) LogPush(*ptr++); //Send the string to the log buffer
+    return ptr - snd;
 }
-void LogV(char *fmt, va_list argptr)
+int LogV(char *fmt, va_list argptr)
 {
     int size  = vsnprintf(NULL, 0, fmt, argptr);  //Find the size required
     char snd[size + 1];                           //Allocate enough memory for the size required with an extra byte for the terminating null
     vsprintf(snd, fmt, argptr);                   //Fill the new buffer
-    Log(snd);                                     //Send the string to the log buffer
+    return Log(snd);                              //Send the string to the log buffer
 }
-void LogF(char *fmt, ...)
+int LogF(char *fmt, ...)
 {
     va_list argptr;
     va_start(argptr, fmt);
-    LogV(fmt, argptr);
+    int size = LogV(fmt, argptr);
     va_end(argptr);
+    return size;
 }
 static void pushuint4(int value)
 {    
@@ -141,7 +144,7 @@
         LogPush(t + '0'); LogPush(u + '0');
     }
 }
-static void logTimeOnly()
+static int logTimeOnly()
 {
     struct tm tm;
     ClockTmUtc(&tm);
@@ -155,19 +158,24 @@
     pushuint2(tm.tm_min);
     LogPush(':');
     pushuint2(tm.tm_sec);
+    return 17;
 }
-void LogTime(char *snd)
+int LogTime(char *snd)
 {
-    logTimeOnly();
-    LogPush(' ');
-    Log(snd);
+    int size = 0;
+    size += logTimeOnly();
+    size++; LogPush(' ');
+    size += Log(snd);
+    return size;
 }
-void LogTimeF(char *fmt, ...)
+int LogTimeF(char *fmt, ...)
 {
+    int size = 0;
     va_list argptr;
     va_start(argptr, fmt);
-    logTimeOnly();
-    LogPush(' ');
-    LogV(fmt, argptr);
+    size == logTimeOnly();
+    size++; LogPush(' ');
+    size += LogV(fmt, argptr);
     va_end(argptr);
+    return size;
 }