-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogger.cpp
More file actions
25 lines (20 loc) · 828 Bytes
/
Logger.cpp
File metadata and controls
25 lines (20 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "Logger.h"
#include <ctime>
using namespace std;
// Logs a Decision Along with the Conditions and Justification
void Logger::logDecision(const string& decision, const string& conditions, const string& justification) {
time_t now = time(0); // Obtain Current Time
struct tm* timeInfo = localtime(&now);
// Format the Timestamp
char buffer[80];
strftime(buffer, sizeof(buffer), "%a %b %d %H:%M:%S %Y", timeInfo);
string formattedTime(buffer);
// Create and Store the Log Entry
logs.push_back("Time: " + formattedTime +
"\n| Driving Conditions |" + conditions +
"\nDecision: " + decision +
"\nJustification: " + justification + "\n");
}
const vector<string>& Logger::getLogs() const {
return logs;
}