logging_serial.h (Source)

/*
* Licence: LGPL
* Autor: Gilhad
*/
#ifndef LOGGING_SERIAL_H
#define LOGGING_SERIAL_H
#include "logging.h"
#include "HardwareSerial.h"
#define SER_LOG_RATE 9600
class logger_serial : public logger{
public:
// konstruktory
logger_serial() : logger() { if (!have_Serial) {Serial.begin(SER_LOG_RATE); have_Serial=true; }; };
logger_serial(const char *name) : logger(name) { if (!have_Serial) {Serial.begin(SER_LOG_RATE); have_Serial=true; }; };
logger_serial(const char *name, int level) : logger(name,level) { if (!have_Serial) {Serial.begin(SER_LOG_RATE); have_Serial=true; }; };
logger_serial(int level) : logger(level) { if (!have_Serial) {Serial.begin(SER_LOG_RATE); have_Serial=true; }; };
protected:
// use Serial
virtual void write(const char *msg);
virtual void write(int msg);
virtual void write(int msg, int type); // write(123,HEX)
virtual void writeln();
private:
static bool have_Serial; // if not, make one
};
#endif