enhance logging function
parent
2383a1bf23
commit
fd423b4e87
|
@ -272,7 +272,7 @@ int EventHandler::pointerHandler(const int type, const int par1, const int par2)
|
|||
else
|
||||
{
|
||||
HideHourglass();
|
||||
Log::writeLog("login failed.");
|
||||
Log::writeErrorLog("login failed.");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -12,9 +12,19 @@
|
|||
#include <string>
|
||||
#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)
|
||||
{
|
||||
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;
|
||||
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);
|
||||
|
||||
log << buffer << ":" << text << "\n";
|
||||
log << buffer << ':' << text << "\n";
|
||||
|
||||
log.close();
|
||||
}
|
|
@ -16,14 +16,28 @@
|
|||
class Log
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Writes a error log entry to the log file
|
||||
*
|
||||
* @param text that shall be written to the log
|
||||
*/
|
||||
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:
|
||||
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);
|
||||
|
||||
private:
|
||||
Log() {}
|
||||
};
|
||||
#endif
|
Loading…
Reference in New Issue