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;
int main(int argc, char *argv[]) {
if (argc < 2) {
std::cerr << "Usage: http_client page [count]" << '\n';
std::cerr << "Usage: http_client page [count]\n";
return 1;
}
......@@ -41,10 +41,10 @@ int main(int argc, char *argv[]) {
resp.then(
[&](Http::Response response) {
++completedRequests;
std::cout << "Response code = " << response.code() << '\n';
std::cout << "Response code = " << response.code() << std::endl;
auto body = response.body();
if (!body.empty())
std::cout << "Response body = " << body << '\n';
std::cout << "Response body = " << body << std::endl;
},
[&](std::exception_ptr exc) {
++failedRequests;
......@@ -69,7 +69,7 @@ int main(int argc, char *argv[]) {
<< std::chrono::duration_cast<std::chrono::milliseconds>(end -
start)
.count()
<< "ms\n";
<< "ms" << std::endl;
client.shutdown();
}
......@@ -57,9 +57,9 @@ private:
if (global > 100) global = 100;
if (global > 1)
std::cout << "Global load is " << global << "%\n";
std::cout << "Global load is " << global << "%" << std::endl;
else
std::cout << "Global load is 0%\n";
std::cout << "Global load is 0%" << std::endl;
},
Async::NoExcept);
......@@ -84,7 +84,7 @@ class MyHandler : public Http::Handler {
auto query = req.query();
if (query.has("chunked")) {
std::cout << "Using chunked encoding\n";
std::cout << "Using chunked encoding" << std::endl;
response.headers()
.add<Header::Server>("pistache/0.1")
......@@ -130,7 +130,7 @@ class MyHandler : public Http::Handler {
else if (req.resource() == "/static") {
if (req.method() == Http::Method::Get) {
Http::serveFile(response, "README.md").then([](ssize_t bytes) {
std::cout << "Sent " << bytes << " bytes\n";
std::cout << "Sent " << bytes << " bytes" << std::endl;
}, Async::NoExcept);
}
} else {
......@@ -164,8 +164,8 @@ int main(int argc, char *argv[]) {
Address addr(Ipv4::any(), port);
std::cout << "Cores = " << hardware_concurrency() << '\n';
std::cout << "Using " << thr << " threads\n";
std::cout << "Cores = " << hardware_concurrency() << std::endl;
std::cout << "Using " << thr << " threads" << std::endl;
auto server = std::make_shared<Http::Endpoint>(addr);
......
......@@ -38,11 +38,11 @@ int main() {
int status = sigwait(&signals, &signal);
if (status == 0)
{
std::cout << "received signal " << signal << '\n';
std::cout << "received signal " << signal << std::endl;
}
else
{
std::cerr << "sigwait returns " << status << '\n';
std::cerr << "sigwait returns " << status << std::endl;
}
server.shutdown();
......
......@@ -144,8 +144,8 @@ int main(int argc, char *argv[]) {
Address addr(Ipv4::any(), port);
std::cout << "Cores = " << hardware_concurrency() << '\n';
std::cout << "Using " << thr << " threads" << '\n';
std::cout << "Cores = " << hardware_concurrency() << std::endl;
std::cout << "Using " << thr << " threads" << std::endl;
BankerService banker(addr);
......
......@@ -14,12 +14,12 @@ using namespace Pistache;
void printCookies(const Http::Request& req) {
auto cookies = req.cookies();
std::cout << "Cookies: [\n";
std::cout << "Cookies: [" << std::endl;
const std::string indent(4, ' ');
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 {
......@@ -157,8 +157,8 @@ int main(int argc, char *argv[]) {
Address addr(Ipv4::any(), port);
std::cout << "Cores = " << hardware_concurrency() << '\n';
std::cout << "Using " << thr << " threads" << '\n';
std::cout << "Cores = " << hardware_concurrency() << std::endl;
std::cout << "Using " << thr << " threads" << std::endl;
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