Restore std::endl in examples

\n is still used when std::endl doesn't make sense, like when using
std::cerr, since it is unbuffered.
parent 0ac27a13
...@@ -14,7 +14,7 @@ using namespace Pistache; ...@@ -14,7 +14,7 @@ using namespace Pistache;
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
if (argc < 2) { if (argc < 2) {
std::cerr << "Usage: http_client page [count]" << '\n'; std::cerr << "Usage: http_client page [count]\n";
return 1; return 1;
} }
...@@ -41,10 +41,10 @@ int main(int argc, char *argv[]) { ...@@ -41,10 +41,10 @@ int main(int argc, char *argv[]) {
resp.then( resp.then(
[&](Http::Response response) { [&](Http::Response response) {
++completedRequests; ++completedRequests;
std::cout << "Response code = " << response.code() << '\n'; std::cout << "Response code = " << response.code() << std::endl;
auto body = response.body(); auto body = response.body();
if (!body.empty()) if (!body.empty())
std::cout << "Response body = " << body << '\n'; std::cout << "Response body = " << body << std::endl;
}, },
[&](std::exception_ptr exc) { [&](std::exception_ptr exc) {
++failedRequests; ++failedRequests;
...@@ -69,7 +69,7 @@ int main(int argc, char *argv[]) { ...@@ -69,7 +69,7 @@ int main(int argc, char *argv[]) {
<< std::chrono::duration_cast<std::chrono::milliseconds>(end - << std::chrono::duration_cast<std::chrono::milliseconds>(end -
start) start)
.count() .count()
<< "ms\n"; << "ms" << std::endl;
client.shutdown(); client.shutdown();
} }
...@@ -57,9 +57,9 @@ private: ...@@ -57,9 +57,9 @@ private:
if (global > 100) global = 100; if (global > 100) global = 100;
if (global > 1) if (global > 1)
std::cout << "Global load is " << global << "%\n"; std::cout << "Global load is " << global << "%" << std::endl;
else else
std::cout << "Global load is 0%\n"; std::cout << "Global load is 0%" << std::endl;
}, },
Async::NoExcept); Async::NoExcept);
...@@ -84,7 +84,7 @@ class MyHandler : public Http::Handler { ...@@ -84,7 +84,7 @@ class MyHandler : public Http::Handler {
auto query = req.query(); auto query = req.query();
if (query.has("chunked")) { if (query.has("chunked")) {
std::cout << "Using chunked encoding\n"; std::cout << "Using chunked encoding" << std::endl;
response.headers() response.headers()
.add<Header::Server>("pistache/0.1") .add<Header::Server>("pistache/0.1")
...@@ -130,7 +130,7 @@ class MyHandler : public Http::Handler { ...@@ -130,7 +130,7 @@ class MyHandler : public Http::Handler {
else if (req.resource() == "/static") { else if (req.resource() == "/static") {
if (req.method() == Http::Method::Get) { if (req.method() == Http::Method::Get) {
Http::serveFile(response, "README.md").then([](ssize_t bytes) { Http::serveFile(response, "README.md").then([](ssize_t bytes) {
std::cout << "Sent " << bytes << " bytes\n"; std::cout << "Sent " << bytes << " bytes" << std::endl;
}, Async::NoExcept); }, Async::NoExcept);
} }
} else { } else {
...@@ -164,8 +164,8 @@ int main(int argc, char *argv[]) { ...@@ -164,8 +164,8 @@ int main(int argc, char *argv[]) {
Address addr(Ipv4::any(), port); Address addr(Ipv4::any(), port);
std::cout << "Cores = " << hardware_concurrency() << '\n'; std::cout << "Cores = " << hardware_concurrency() << std::endl;
std::cout << "Using " << thr << " threads\n"; std::cout << "Using " << thr << " threads" << std::endl;
auto server = std::make_shared<Http::Endpoint>(addr); auto server = std::make_shared<Http::Endpoint>(addr);
......
...@@ -38,11 +38,11 @@ int main() { ...@@ -38,11 +38,11 @@ int main() {
int status = sigwait(&signals, &signal); int status = sigwait(&signals, &signal);
if (status == 0) if (status == 0)
{ {
std::cout << "received signal " << signal << '\n'; std::cout << "received signal " << signal << std::endl;
} }
else else
{ {
std::cerr << "sigwait returns " << status << '\n'; std::cerr << "sigwait returns " << status << std::endl;
} }
server.shutdown(); server.shutdown();
......
...@@ -144,8 +144,8 @@ int main(int argc, char *argv[]) { ...@@ -144,8 +144,8 @@ int main(int argc, char *argv[]) {
Address addr(Ipv4::any(), port); Address addr(Ipv4::any(), port);
std::cout << "Cores = " << hardware_concurrency() << '\n'; std::cout << "Cores = " << hardware_concurrency() << std::endl;
std::cout << "Using " << thr << " threads" << '\n'; std::cout << "Using " << thr << " threads" << std::endl;
BankerService banker(addr); BankerService banker(addr);
......
...@@ -14,12 +14,12 @@ using namespace Pistache; ...@@ -14,12 +14,12 @@ using namespace Pistache;
void printCookies(const Http::Request& req) { void printCookies(const Http::Request& req) {
auto cookies = req.cookies(); auto cookies = req.cookies();
std::cout << "Cookies: [\n"; std::cout << "Cookies: [" << std::endl;
const std::string indent(4, ' '); const std::string indent(4, ' ');
for (const auto& c: cookies) { for (const auto& c: cookies) {
std::cout << indent << c.name << " = " << c.value << '\n'; std::cout << indent << c.name << " = " << c.value << std::endl;
} }
std::cout << "]\n"; std::cout << "]" << std::endl;
} }
namespace Generic { namespace Generic {
...@@ -157,8 +157,8 @@ int main(int argc, char *argv[]) { ...@@ -157,8 +157,8 @@ int main(int argc, char *argv[]) {
Address addr(Ipv4::any(), port); Address addr(Ipv4::any(), port);
std::cout << "Cores = " << hardware_concurrency() << '\n'; std::cout << "Cores = " << hardware_concurrency() << std::endl;
std::cout << "Using " << thr << " threads" << '\n'; std::cout << "Using " << thr << " threads" << std::endl;
StatsEndpoint stats(addr); StatsEndpoint stats(addr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment