enhance logging function
parent
2383a1bf23
commit
fd423b4e87
|
@ -272,7 +272,7 @@ int EventHandler::pointerHandler(const int type, const int par1, const int par2)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HideHourglass();
|
HideHourglass();
|
||||||
Log::writeLog("login failed.");
|
Log::writeErrorLog("login failed.");
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,19 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
void Log::writeInfoLog(const std::string &text)
|
||||||
|
{
|
||||||
|
writeLog("Info:" + text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Log::writeErrorLog(const std::string &text)
|
||||||
|
{
|
||||||
|
writeLog("Error:" + text);
|
||||||
|
}
|
||||||
|
|
||||||
void Log::writeLog(const std::string &text)
|
void Log::writeLog(const std::string &text)
|
||||||
{
|
{
|
||||||
std::ofstream log(LOG_PATH + std::string("/logfile.txt"), std::ios_base::app | std::ios_base::out);
|
std::ofstream log(CONFIG_FOLDER + std::string("/logfile.txt"), std::ios_base::app | std::ios_base::out);
|
||||||
|
|
||||||
time_t rawtime;
|
time_t rawtime;
|
||||||
struct tm *timeinfo;
|
struct tm *timeinfo;
|
||||||
|
@ -25,7 +35,7 @@ void Log::writeLog(const std::string &text)
|
||||||
|
|
||||||
strftime(buffer, sizeof(buffer), "%d/%b/%Y:%H:%M:%S %z", timeinfo);
|
strftime(buffer, sizeof(buffer), "%d/%b/%Y:%H:%M:%S %z", timeinfo);
|
||||||
|
|
||||||
log << buffer << ":" << text << "\n";
|
log << buffer << ':' << text << "\n";
|
||||||
|
|
||||||
log.close();
|
log.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,13 +17,27 @@ class Log
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Writes a log entry to the log file
|
* Writes a error log entry to the log file
|
||||||
*
|
*
|
||||||
* @param text that shall be written to the log
|
* @param text that shall be written to the log
|
||||||
*/
|
*/
|
||||||
static void writeLog(const std::string &text);
|
static void writeErrorLog(const std::string &text);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes a info log entry to the log file
|
||||||
|
*
|
||||||
|
* @param text that shall be written to the log
|
||||||
|
*/
|
||||||
|
static void writeInfoLog(const std::string &text);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Log() {}
|
Log() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes a log entry to the log file
|
||||||
|
*
|
||||||
|
* @param text that shall be written to the log
|
||||||
|
*/
|
||||||
|
static void writeLog(const std::string &text);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue