1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2025-12-16 07:23:07 +01:00

use nonblocking write for serial

This commit is contained in:
andreas
2021-10-25 21:20:41 +02:00
parent 8c02b21277
commit 60eabb05ab
5 changed files with 161 additions and 25 deletions

View File

@@ -1,17 +1,25 @@
#ifndef _GWLOG_H
#define _GWLOG_H
#include <Arduino.h>
class GwLogWriter{
public:
virtual ~GwLogWriter(){}
virtual void write(const char *data)=0;
};
class GwLog{
private:
char buffer[100];
bool logSerial=false;
int logLevel=1;
GwLogWriter *writer;
public:
static const int LOG=1;
static const int ERROR=0;
static const int DEBUG=3;
static const int TRACE=2;
GwLog(bool logSerial,int level=LOG);
String prefix="LOG:";
GwLog(int level=LOG, GwLogWriter *writer=NULL);
void setWriter(GwLogWriter *writer);
void logString(const char *fmt,...);
void logDebug(int level, const char *fmt,...);
int isActive(int level){return level <= logLevel;};