// // Created by Nik on 20/05/2022. // #include "Log.h" #include Log::Log(LogType type) { file.open(fileName,std::ios_base::out | std::ios_base::app); time_t now = time(0); tm* strucTime = localtime(&now); std::string time; time = std::to_string(strucTime->tm_year + 1900) + "-" + std::to_string(strucTime->tm_mon + 1) + "-" + std::to_string(strucTime->tm_mday) + " " + std::to_string(strucTime->tm_hour) + ":" + std::to_string(strucTime->tm_min) + ":" + std::to_string(strucTime->tm_sec) + " "; operator<<(time + GetStringLogType(type)); } Log::~Log() { file.close(); } std::string Log::GetStringLogType(LogType type) { switch (type) { case LogType::ERROR: return "[ERROR] "; case LogType::INFO: return "[INFO] "; case LogType::DEBUG: return "[DEBUG] "; } return "ERROR"; }