| LightHub v4.0.0 Smarthome controller firmware

streamlog.h
Go to the documentation of this file.
1 #pragma once
2 #include <Print.h>
3 #include <Arduino.h>
4 #include <HardwareSerial.h>
5 #include <inttypes.h>
6
7 #if defined (STM32)
8 #include <USBSerial.h>
9 #endif
10
11 #ifndef LOGBUFFER_SIZE
12 #define LOGBUFFER_SIZE 80
13 #endif
14
15 #ifdef SYSLOG_ENABLE
16 #include <Syslog.h>
17 #endif
18
19 extern uint8_t serialDebugLevel;
20 extern uint8_t udpDebugLevel;
21
22
23 #ifndef SerialPortType
24 #define SerialPortType HardwareSerial
25 #endif
26
27 #define LOG_DEBUG 7
28 #define LOG_INFO 6
29 #define LOG_ERROR 3
30
31 class Streamlog : public Print
32 {
33 public:
34 #ifdef SYSLOG_ENABLE
35 Streamlog (SerialPortType * _serialPort, uint8_t _severity = LOG_DEBUG, Syslog * _syslog = NULL, uint8_t _ledPattern = 0);
36 #else
37 Streamlog (SerialPortType * _serialPort, uint8_t _severity = LOG_DEBUG, uint8_t _ledPattern = 0);
38 #endif
39 void begin(unsigned long speed);
40 void end() ;
41
42 int available(void);
43 int peek(void);
44 int read(void);
45 void flush(void);
46 size_t write(uint8_t ch);
47 using Print::write; // pull in write(str) and write(buf, size) from Print
48 operator bool() {return true;};
49 private:
50 uint8_t severity;
51 SerialPortType *serialPort;
52 uint8_t ledPattern;
53 #ifdef SYSLOG_ENABLE
54 Syslog * syslog;
55 #endif
56 };
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