Add time to logging

This commit is contained in:
Benjamin Loison 2022-12-22 05:47:16 +01:00
parent 6685c13706
commit 273537bc8d

View File

@ -119,6 +119,15 @@ void treatComment(json comment)
commentsCount++;
}
string getDate()
{
auto t = time(nullptr);
auto tm = *localtime(&t);
ostringstream toString;
toString << put_time(&tm, "%d-%m-%Y %H-%M-%S");
return toString.str();
}
vector<string> getFileContent(string filePath)
{
vector<string> lines;
@ -139,7 +148,7 @@ json getJson(string url)
void print(ostringstream* toPrint)
{
cout << toPrint->str() << endl;
cout << getDate() << ": " << toPrint->str() << endl;
toPrint->str("");
}