Replace std::endl with "\n"

This commit is contained in:
badaix 2024-12-19 23:35:12 +01:00
parent 709cd362e1
commit a79b3e6599

View file

@ -172,7 +172,7 @@ int main(int argc, char* argv[])
} }
catch (const std::invalid_argument& e) catch (const std::invalid_argument& e)
{ {
cerr << "Exception: " << e.what() << std::endl; cerr << "Exception: " << e.what() << "\n";
cout << "\n" << op << "\n"; cout << "\n" << op << "\n";
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -209,9 +209,9 @@ int main(int argc, char* argv[])
std::unique_ptr<encoder::Encoder> encoder(encoderFactory.createEncoder(settings.stream.codec)); std::unique_ptr<encoder::Encoder> encoder(encoderFactory.createEncoder(settings.stream.codec));
if (encoder) if (encoder)
{ {
cout << "Options for codec \"" << encoder->name() << "\":\n" cout << "Options for codec '" << encoder->name() << "':\n"
<< " " << encoder->getAvailableOptions() << "\n" << " " << encoder->getAvailableOptions() << "\n"
<< " Default: \"" << encoder->getDefaultOptions() << "\"\n"; << " Default: '" << encoder->getDefaultOptions() << "'\n";
} }
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
@ -293,9 +293,9 @@ int main(int argc, char* argv[])
processPriority = std::min(std::max(-20, processPriority), 19); processPriority = std::min(std::max(-20, processPriority), 19);
if (processPriority != 0) if (processPriority != 0)
setpriority(PRIO_PROCESS, 0, processPriority); setpriority(PRIO_PROCESS, 0, processPriority);
LOG(NOTICE, LOG_TAG) << "daemonizing" << std::endl; LOG(NOTICE, LOG_TAG) << "daemonizing" << "\n";
daemon->daemonize(); daemon->daemonize();
LOG(NOTICE, LOG_TAG) << "daemon started" << std::endl; LOG(NOTICE, LOG_TAG) << "daemon started" << "\n";
} }
else else
Config::instance().init(settings.server.data_dir); Config::instance().init(settings.server.data_dir);
@ -351,9 +351,8 @@ int main(int argc, char* argv[])
// Construct a signal set registered for process termination. // Construct a signal set registered for process termination.
boost::asio::signal_set signals(io_context, SIGHUP, SIGINT, SIGTERM); boost::asio::signal_set signals(io_context, SIGHUP, SIGINT, SIGTERM);
signals.async_wait( signals.async_wait([&io_context](const boost::system::error_code& ec, int signal)
[&io_context](const boost::system::error_code& ec, int signal) {
{
if (!ec) if (!ec)
LOG(INFO, LOG_TAG) << "Received signal " << signal << ": " << strsignal(signal) << "\n"; LOG(INFO, LOG_TAG) << "Received signal " << signal << ": " << strsignal(signal) << "\n";
else else
@ -362,6 +361,7 @@ int main(int argc, char* argv[])
}); });
std::vector<std::thread> threads; std::vector<std::thread> threads;
threads.reserve(settings.server.threads);
for (int n = 0; n < settings.server.threads; ++n) for (int n = 0; n < settings.server.threads; ++n)
threads.emplace_back([&] { io_context.run(); }); threads.emplace_back([&] { io_context.run(); });
@ -370,16 +370,16 @@ int main(int argc, char* argv[])
for (auto& t : threads) for (auto& t : threads)
t.join(); t.join();
LOG(INFO, LOG_TAG) << "Stopping streamServer" << endl; LOG(INFO, LOG_TAG) << "Stopping streamServer\n";
server->stop(); server->stop();
LOG(INFO, LOG_TAG) << "done" << endl; LOG(INFO, LOG_TAG) << "done\n";
} }
catch (const std::exception& e) catch (const std::exception& e)
{ {
LOG(ERROR, LOG_TAG) << "Exception: " << e.what() << std::endl; LOG(ERROR, LOG_TAG) << "Exception: " << e.what() << "\n";
exitcode = EXIT_FAILURE; exitcode = EXIT_FAILURE;
} }
Config::instance().save(); Config::instance().save();
LOG(NOTICE, LOG_TAG) << "Snapserver terminated." << endl; LOG(NOTICE, LOG_TAG) << "Snapserver terminated.\n";
exit(exitcode); exit(exitcode);
} }