1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-09-02 10:53:01 +02:00

Fixed logging - Serial -> Uart0

This commit is contained in:
Mitch Bradley
2021-05-21 10:06:57 -10:00
parent 181b81a66b
commit 02c141edad
2 changed files with 20 additions and 15 deletions

View File

@@ -2,30 +2,35 @@
#ifndef ESP32 #ifndef ESP32
#include <iostream> # include <iostream>
DebugStream::DebugStream(const char* name) { DebugStream::DebugStream(const char* name) {
std::cout << '[' << name << ": "; std::cout << '[' << name << ": ";
} }
void DebugStream::add(char c) void DebugStream::add(char c) {
{
std::cout << c; std::cout << c;
} }
DebugStream::~DebugStream() { std::cout << ']' << std::endl; } DebugStream::~DebugStream() {
std::cout << ']' << std::endl;
}
#else #else
#include <Arduino.h> # include "Uart.h"
DebugStream::DebugStream(const char* name) { DebugStream::DebugStream(const char* name) {
Serial.print("["); Uart0.print("[");
Serial.print(name); Uart0.print(name);
Serial.print(": "); Uart0.print(": ");
} }
void DebugStream::add(char c) { Serial.print(c); } void DebugStream::add(char c) {
Uart0.print(c);
}
DebugStream::~DebugStream() { Serial.println("]"); } DebugStream::~DebugStream() {
Uart0.println("]");
}
#endif #endif

View File

@@ -25,31 +25,31 @@ public:
#include "StringStream.h" #include "StringStream.h"
// Note: these '{'..'}' scopes are here for a reason: the destructor should flush. // Note: these '{'..'}' scopes are here for a reason: the destructor should flush.
#define log_debug(x) \ #define log_debug(x) \
{ \ { \
DebugStream ss("DBG "); \ DebugStream ss("DBG "); \
ss << x; \ ss << x; \
} }
#define log_info(x) \ #define log_info(x) \
{ \ { \
DebugStream ss("INFO"); \ DebugStream ss("INFO"); \
ss << x; \ ss << x; \
} }
#define log_warn(x) \ #define log_warn(x) \
{ \ { \
DebugStream ss("WARN"); \ DebugStream ss("WARN"); \
ss << x; \ ss << x; \
} }
#define log_error(x) \ #define log_error(x) \
{ \ { \
DebugStream ss("ERR "); \ DebugStream ss("ERR "); \
ss << x; \ ss << x; \
} }
#define log_fatal(x) \ #define log_fatal(x) \
{ \ { \
DebugStream ss("FATAL "); \ DebugStream ss("FATAL "); \
ss << x; \ ss << x; \