Add time to logging

This commit is contained in:
Benjamin Loison 2022-12-22 05:47:16 +01:00
parent eaae954e1b
commit 934954092a
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8

View File

@ -119,6 +119,15 @@ void treatComment(json comment)
commentsCount++; 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> getFileContent(string filePath)
{ {
vector<string> lines; vector<string> lines;
@ -139,7 +148,7 @@ json getJson(string url)
void print(ostringstream* toPrint) void print(ostringstream* toPrint)
{ {
cout << toPrint->str() << endl; cout << getDate() << ": " << toPrint->str() << endl;
toPrint->str(""); toPrint->str("");
} }