|
/*
|
|
* Licence: LGPL
|
|
* Autor: Gilhad
|
|
*/
|
|
|
|
#ifndef LOGGING_H
|
|
#define LOGGING_H
|
|
|
|
#define LOG_NONE 0
|
|
#define LOG_INFO 20
|
|
#define LOG_ERROR 40
|
|
class logger{
|
|
public:
|
|
|
|
// konstruktory
|
|
logger();
|
|
logger(const char *name);
|
|
logger(const char *name, int level);
|
|
logger(int level);
|
|
|
|
// destruktor
|
|
virtual ~logger();
|
|
|
|
const char *name;
|
|
int set_level; // hladina, od ktere se loguje
|
|
|
|
virtual void log(int level, const char *msg);
|
|
virtual void log(int level, const char *msg, const char *param);
|
|
virtual void log(int level, const char *msg, int param);
|
|
virtual void log(int level, const char *msg, int param, int type);
|
|
|
|
// oblíbené zkratky pro info a error
|
|
void info( const char *msg) { log(LOG_INFO,msg); }; // info("OK") => "OK"
|
|
void info( const char *msg, const char *param) { log(LOG_INFO,msg,param); }; // info("Not a number ", data) => "Not a number TEST"
|
|
void info( const char *msg, int param) { log(LOG_INFO,msg,param); }; // info("Not positive ", number) => "Not positive -12"
|
|
void info( const char *msg, int param, int type) { log(LOG_INFO,msg,param,type); }; // info("Bad bitmask ", number, BIN) => "Bad bitmask 10101010"
|
|
|
|
void error( const char *msg) { log(LOG_ERROR,msg); };
|
|
void error( const char *msg, const char *param) { log(LOG_ERROR,msg,param); };
|
|
void error( const char *msg, int param) { log(LOG_ERROR,msg,param); };
|
|
void error( const char *msg, int param, int type) { log(LOG_ERROR,msg,param,type); };
|
|
|
|
|
|
protected: // teprve zde se používá Serial
|
|
|
|
virtual void write(const char *msg)=0;
|
|
virtual void write(int msg)=0;
|
|
virtual void write(int msg, int type)=0; // write(123,HEX)
|
|
virtual void writeln()=0;
|
|
};
|
|
#endif
|