statustime: No empty lines, flush before exit.

This commit is contained in:
tastytea 2021-08-15 15:40:38 +02:00
parent 2f80b3573b
commit 677222fa12
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 5 additions and 3 deletions

View File

@ -17,7 +17,8 @@ void signal_handler(int signum)
case SIGTERM:
case SIGINT:
{
std::cout << "\n<span color='red'>Time script terminated.</span>\n";
std::cout << R"(<span color="red">Time script terminated.</span>)"
<< std::endl;
std::exit(signum); // NOLINT(concurrency-mt-unsafe)
break;
}
@ -32,6 +33,7 @@ int main()
{
using fmt::format;
using std::cout;
using std::endl;
using clock = std::chrono::system_clock;
using std::chrono::minutes;
using namespace std::chrono_literals;
@ -51,7 +53,7 @@ int main()
R"({0:%Y-%m-%d} )"
R"(<span color="lightcyan">{0:%H:%M}</span>)",
now)
<< std::endl; // NOTE: Don't forget that we need to flush! 😊
<< endl; // NOTE: Don't forget that we need to flush! 😊
const auto next_minute{std::chrono::floor<minutes>(now + 1min)};
std::this_thread::sleep_until(next_minute);
@ -59,7 +61,7 @@ int main()
}
catch (const std::exception &e)
{
cout << "\n<span color='red'>Error: Time script crashed.</span>\n";
cout << R"(<span color="red">Time script crashed.</span>)" << endl;
std::cerr << e.what() << '\n';
return 33;
}