logging.cpp (Source)

/*
* Licence: LGPL
* Autor: Gilhad
*/
#include "logging.h"
// konstruktory
logger::logger():name("log"),set_level(LOG_NONE){};
logger::logger(const char *name,int level):name(name),set_level(level){};
logger::logger(const char *name):name(name),set_level(LOG_NONE){};
logger::logger(int level):name("log"),set_level(level){};
//destruktor
logger::~logger(){};
// metody pro přímý výstup
void logger::log(int level, const char *msg){ // {{{
if (level >= set_level) {
switch (level)  {
case LOG_NONE:write("#NONE: ");break;
case LOG_INFO:write("#INFO: ");break;
case LOG_ERROR:write("#ERROR: ");break;
default:write("#E_");write(level);write(": ");break;
};
if (name) write(name);
write(": ");
if (msg) write(msg);
writeln();
};
}; // }}}
void logger::log(int level, const char *msg, const char *param){ // {{{
if (level >= set_level) {
switch (level)  {
case LOG_NONE:write("#NONE: ");break;
case LOG_INFO:write("#INFO: ");break;
case LOG_ERROR:write("#ERROR: ");break;
default:write("#E_");write(level);write(": ");break;
};
if (name) write(name);
write(": ");
if (msg) write(msg);
if (param) write(param);
writeln();
};
}; // }}}
void logger::log(int level, const char *msg, int param){ // {{{
if (level >= set_level) {
switch (level)  {
case LOG_NONE:write("#NONE: ");break;
case LOG_INFO:write("#INFO: ");break;
case LOG_ERROR:write("#ERROR: ");break;
default:write("#E_");write(level);write(": ");break;
};
if (name) write(name);
write(": ");
if (msg) write(msg);
write(param);
writeln();
};
}; // }}}
void logger::log(int level, const char *msg, int param, int type){ // {{{
if (level >= set_level) {
switch (level)  {
case LOG_NONE:write("#NONE: ");break;
case LOG_INFO:write("#INFO: ");break;
case LOG_ERROR:write("#ERROR: ");break;
default:write("#E_");write(level);write(": ");break;
};
if (name) write(name);
write(": ");
if (msg) write(msg);
write(param,type);
writeln();
};
}; // }}}