Added a printf version of the print_logs. I need to add timers for both methods to see which one I would like to use.
This commit is contained in:
@@ -88,7 +88,11 @@ std::string p_logs::entryx_browser(int x){
|
||||
return logs[x].browser;
|
||||
}
|
||||
|
||||
|
||||
// TO DO: TIME THE DIFFERENCE BETWEEN THESE TWO PRINTING METHODS
|
||||
void p_logs::print_logs() {
|
||||
|
||||
// Simple printing
|
||||
for (const auto& log : logs) {
|
||||
std::cout << "IP: " << log.ip.c_str() << "\n"
|
||||
<< "Timestamp: " << log.timestamp.c_str() << "\n"
|
||||
@@ -99,5 +103,29 @@ void p_logs::print_logs() {
|
||||
<< "OS: " << log.os.c_str() << "\n"
|
||||
<< "Browser: " << log.browser.c_str() << "\n\n"
|
||||
<< "-----------------------------\n\n";
|
||||
|
||||
}
|
||||
|
||||
// Faster Printing?
|
||||
for (const auto& log : logs) {
|
||||
std::printf(
|
||||
"IP: %s\n"
|
||||
"Timestamp: %s\n"
|
||||
"Request: %s\n"
|
||||
"Status: %s\n"
|
||||
"Bytes: %s\n"
|
||||
"Referer: %s\n"
|
||||
"OS: %s\n"
|
||||
"Browser: %s\n\n"
|
||||
"-----------------------------\n\n",
|
||||
log.ip.c_str(),
|
||||
log.timestamp.c_str(),
|
||||
log.request.c_str(),
|
||||
log.status.c_str(),
|
||||
log.bytes.c_str(),
|
||||
log.referer.c_str(),
|
||||
log.os.c_str(),
|
||||
log.browser.c_str()
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user