Helpful logging and error format

Dependents:   Waldo_Embed_V2

Inspired by this blog post.

Work in Progress

Files at this revision

API Documentation at this revision

Comitter:
sam_grove
Date:
Sun Dec 18 01:30:53 2022 +0000
Parent:
7:ef45bd2cd9bb
Commit message:
Update to be dependent on buffered serial not blocking serial

Changed in this revision

LogUtil.cpp Show annotated file Show diff for this revision Revisions of this file
LogUtil.h Show annotated file Show diff for this revision Revisions of this file
diff -r ef45bd2cd9bb -r 509ffcfb849f LogUtil.cpp
--- a/LogUtil.cpp	Fri May 10 18:36:27 2013 +0000
+++ b/LogUtil.cpp	Sun Dec 18 01:30:53 2022 +0000
@@ -23,7 +23,7 @@
  #include "LogUtil.h"
  #include "mbed.h"
  
-LogUtil::LogUtil(Serial &serial, uint32_t baudrate)
+LogUtil::LogUtil(BufferedSerial &serial, uint32_t baudrate)
 {
     _serial = &serial;
     (baudrate > 0) ? _serial->baud(baudrate) : __nop();
diff -r ef45bd2cd9bb -r 509ffcfb849f LogUtil.h
--- a/LogUtil.h	Fri May 10 18:36:27 2013 +0000
+++ b/LogUtil.h	Sun Dec 18 01:30:53 2022 +0000
@@ -25,18 +25,18 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include "mbed.h"
+#include "BufferedSerial.h"
 
 #define STREAM      stdout
-#define LOG(...)    \
+#define LLOG(...)    \
     fprintf(STREAM, "LOG:   %s L#%d ", __PRETTY_FUNCTION__, __LINE__);  \
     fprintf(STREAM, ##__VA_ARGS__); \
     fflush(STREAM)
-#define WARN(...)   \
+#define WWARN(...)   \
     fprintf(STREAM, "WARN:  %s L#%d ", __PRETTY_FUNCTION__, __LINE__);  \
     fprintf(STREAM, ##__VA_ARGS__); \
     fflush(STREAM)
-#define ERROR(...)  \
+#define EERROR(...)  \
     fprintf(STREAM, "ERROR: %s L#%d ", __PRETTY_FUNCTION__, __LINE__); \
     fprintf(STREAM, ##__VA_ARGS__); \
     fflush(STREAM); \
@@ -76,12 +76,12 @@
 class LogUtil
 {
 private:
-    Serial *_serial;
+    BufferedSerial *_serial;
 public:
     
     /** Construct the LogUtil class and configure
      */
-    LogUtil(Serial &serial, uint32_t baudrate = 0);
+    LogUtil(BufferedSerial &serial, uint32_t baudrate = 0);
         
 };