# LightHub: streamlog.h Source File

streamlog.h
Go to the documentation of this file.
#include <Print.h>
#include <HardwareSerial.h>
#include <inttypes.h>
#ifndef LOGBUFFER_SIZE
#define LOGBUFFER_SIZE 80
#endif
#ifdef SYSLOG_ENABLE
#include <Syslog.h>
static char logBuffer[LOGBUFFER_SIZE];
static int logBufferPos=0;
#endif
#define LOG_DEBUG 7
#define LOG_INFO 6
#define LOG_ERROR 3
static uint8_t serialDebugLevel = 7;
static uint8_t udpDebugLevel =7;
class Streamlog : public Print
{
public:
#ifdef SYSLOG_ENABLE
Streamlog (HardwareSerial * _serialPort, int _severity = LOG_DEBUG, Syslog * _syslog = NULL, uint8_t _ledPattern = 0);
#else
Streamlog (HardwareSerial * _serialPort, int _severity = LOG_DEBUG, uint8_t _ledPattern = 0);
#endif
// {serialPort=_serialPort;severity=_severity; syslog=_syslog; }
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:
uint16_t severity;
HardwareSerial *serialPort;
#ifdef SYSLOG_ENABLE
Syslog * syslog;
uint8_t ledPattern;
#endif
};
Streamlog::end
void end()
Definition: streamlog.cpp:31
Streamlog::available
int available(void)
Definition: streamlog.cpp:36
LOGBUFFER_SIZE
#define LOGBUFFER_SIZE
Definition: streamlog.h:6
Streamlog::write
size_t write(uint8_t ch)
Definition: streamlog.cpp:61
Streamlog::flush
void flush(void)
Definition: streamlog.cpp:55
Streamlog::peek
int peek(void)
Definition: streamlog.cpp:42
Streamlog::begin
void begin(unsigned long speed)
Definition: streamlog.cpp:26
Streamlog
Definition: streamlog.h:23
Streamlog::read
int read(void)
Definition: streamlog.cpp:48
Streamlog::Streamlog
Streamlog(HardwareSerial *_serialPort, int _severity=LOG_DEBUG, uint8_t _ledPattern=0)
Definition: streamlog.cpp:19
LOG_DEBUG
#define LOG_DEBUG
Definition: streamlog.h:15