streamlog.h
Go to the documentation of this file.
#pragma once
#include <Print.h>
#include <Arduino.h>
#include <HardwareSerial.h>
#include <inttypes.h>
#if defined (STM32)
#include <USBSerial.h>
#endif
#ifndef LOGBUFFER_SIZE
#define LOGBUFFER_SIZE 80
#endif
#ifdef SYSLOG_ENABLE
#include <Syslog.h>
#endif
extern uint8_t serialDebugLevel;
extern uint8_t udpDebugLevel;
#ifndef SerialPortType
#define SerialPortType HardwareSerial
#endif
#define LOG_DEBUG 7
#define LOG_INFO 6
#define LOG_ERROR 3
class Streamlog : public Print
{
public:
#ifdef SYSLOG_ENABLE
Streamlog (SerialPortType * _serialPort, uint8_t _severity = LOG_DEBUG, Syslog * _syslog = NULL, uint8_t _ledPattern = 0);
#else
Streamlog (SerialPortType * _serialPort, uint8_t _severity = LOG_DEBUG, uint8_t _ledPattern = 0);
#endif
void begin(unsigned long speed);
void end() ;
int available(void);
int peek(void);
int read(void);
void flush(void);
size_t write(uint8_t ch);
using Print::write; // pull in write(str) and write(buf, size) from Print
operator bool() {return true;};
private:
uint8_t severity;
SerialPortType *serialPort;
uint8_t ledPattern;
#ifdef SYSLOG_ENABLE
Syslog * syslog;
#endif
};
udpDebugLevel
uint8_t udpDebugLevel
Definition: streamlog.cpp:11
Streamlog::end
void end()
Definition: streamlog.cpp:39
Streamlog::available
int available(void)
Definition: streamlog.cpp:44
Streamlog::Streamlog
Streamlog(SerialPortType *_serialPort, uint8_t _severity=LOG_DEBUG, uint8_t _ledPattern=0)
Definition: streamlog.cpp:27
Streamlog::write
size_t write(uint8_t ch)
Definition: streamlog.cpp:69
SerialPortType
#define SerialPortType
Definition: streamlog.h:24
Streamlog::flush
void flush(void)
Definition: streamlog.cpp:63
Streamlog::peek
int peek(void)
Definition: streamlog.cpp:50
Streamlog::begin
void begin(unsigned long speed)
Definition: streamlog.cpp:34
Streamlog
Definition: streamlog.h:32
Streamlog::read
int read(void)
Definition: streamlog.cpp:56
serialDebugLevel
uint8_t serialDebugLevel
Definition: streamlog.cpp:10
LOG_DEBUG
#define LOG_DEBUG
Definition: streamlog.h:27