logging.cpp 667 Bytes
#include "logging.h"

namespace util {

	Logging* Logging::l_instance = NULL;
	logLevel Logging::l_level = _INFO;

	Logging* Logging::instance() {
		if(!l_instance)
			l_instance = new Logging();
		return l_instance;
	}

	logLevel Logging::getLevel() {
		return this->l_level;
	}

	void Logging::setLevel(logLevel level) {
		if(level != 0)
			this->l_level = level;
	}

	char* Logging::getTime() {
		time_t curtime;
   		time(&curtime);
        return ctime(&curtime);
    }

	void Logging::writeLog(const char* logMsg) {
		l_file = fopen(LOG_FILE, "a");
		
		if(l_file == NULL)
			return;

		fprintf(l_file, "%s'%s'\n\n\r", getTime() ,logMsg);
		fclose(l_file);
	}
}