-
Notifications
You must be signed in to change notification settings - Fork 0
/
AbstractLog.h
56 lines (52 loc) · 1.62 KB
/
AbstractLog.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef ABSTRACTLOG_H
#define ABSTRACTLOG_H
#include <Arduino.h>
#include "configuration\Configuration.h"
namespace Tinker{
//! Abstract interface for any logger
/*!
Every object that should act as a logger must inherit from this class.
\author Nicola Pezzotti
*/
class AbstractLog{
public:
//! Endline.
virtual void endline()=0;
//! Display a character array.
virtual void display(char* str)=0;
//! Display a byte value.
virtual void display(byte v)=0;
//! Display a float value.
virtual void display(float v)=0;
//! Display a double value.
virtual void display(double v)=0;
//! Display an integer value.
virtual void display(int v)=0;
//! Display an unsigned int value.
virtual void display(unsigned int v)=0;
//! Display an unsigned long value.
virtual void display(unsigned long v)=0;
//! Clear the logger.
virtual void clear()=0;
};
}
#ifdef ENABLE_LOGGER
#define SECURE_LOG(logptr,val){if((logptr)!=0){(logptr)->display(val);(logptr)->endline();}}
#define SECURE_LOG_VAL(logptr,name,val){if((logptr)!=0){(logptr)->display(name);(logptr)->display(": ");(logptr)->display(val);(logptr)->endline();}}
#define SECURE_LOG_CLEAR(logptr){if((logptr)!=0){(logptr)->clear();}}
#define SECURE_LOG_ONOFF(logptr,name,v){\
if((logptr)!=0){\
if(v){\
(logptr)->display(name);(logptr)->display(": ON");(logptr)->endline();\
}else{\
(logptr)->display(name);(logptr)->display(": OFF");(logptr)->endline();\
}\
}\
}
#else
#define SECURE_LOG(logptr,val){}
#define SECURE_LOG_VAL(logptr,name,val){}
#define SECURE_LOG_CLEAR(logptr){}
#define SECURE_LOG_ONOFF(logptr,name,v){}
#endif
#endif