Skip to content
Snippets Groups Projects
Commit d992e7e2 authored by Nubben's avatar Nubben
Browse files

Use logging instead of cout in main

parent 61d19a56
No related branches found
No related tags found
No related merge requests found
......@@ -2,4 +2,4 @@
physicalCpuCount=$([[ $(uname) = 'Darwin' ]] &&
sysctl -n hw.physicalcpu_max ||
lscpu -p | egrep -v '^#' | sort -u -t, -k 2,4 | wc -l)
make -j$physicalCpuCount && ./netrunner http://motherfuckingwebsite.com/
make -j$physicalCpuCount && ./netrunner http://motherfuckingwebsite.com/ -log debug
......@@ -11,6 +11,7 @@
#include "WebResource.h"
#include "CommandLineParams.h"
#include "URL.h"
#include "Log.h"
const std::unique_ptr<Window> window = std::make_unique<Window>();
URL currentURL;
......@@ -20,7 +21,7 @@ bool setWindowContent(URL const& url);
bool setWindowContent(URL const& url) {
WebResource res = getWebResource(url);
if (res.resourceType == ResourceType::INVALID) {
std::cout << "Invalid resource type: " << res.raw << std::endl;
logError() << "Invalid resource type: " << res.raw << std::endl;
return false;
}
......@@ -28,15 +29,15 @@ bool setWindowContent(URL const& url) {
const std::clock_t begin = clock();
std::shared_ptr<Node> rootNode = parser.parse(res.raw);
const std::clock_t end = clock();
std::cout << "Parsed document in: " << std::fixed << ((static_cast<double>(end - begin)) / CLOCKS_PER_SEC) << std::scientific << " seconds" << std::endl;
logDebug() << "Parsed document in: " << std::fixed << ((static_cast<double>(end - begin)) / CLOCKS_PER_SEC) << std::scientific << " seconds" << std::endl;
window->setDOM(rootNode);
return true;
}
void navTo(std::string url) {
std::cout << "navTo(" << url << ")" << std::endl;
logDebug() << "navTo(" << url << ")" << std::endl;
currentURL = currentURL.merge(URL(url));
std::cout << "go to: " << currentURL << std::endl;
logDebug() << "go to: " << currentURL << std::endl;
setWindowContent(currentURL);
}
......@@ -45,14 +46,15 @@ int main(int argc, char *argv[]) {
std::cout << "./netrunner <url|file.html>" << std::endl;
return 1;
}
initCLParams(argc, argv);
std::cout << "/g/ntr - NetRunner build " << __DATE__ << std::endl;
initCLParams(argc, argv);
std::string url = getCLParamByIndex(1);
if (url[0] == '/') {
url = "file://" + url;
}
currentURL=URL(url);
std::cout << "loading [" << currentURL << "]" << std::endl;
logDebug() << "loading [" << currentURL << "]" << std::endl;
if (!setWindowContent(currentURL)) {
return 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment