statustime: No empty lines, flush before exit.
This commit is contained in:
parent
2f80b3573b
commit
677222fa12
@ -17,7 +17,8 @@ void signal_handler(int signum)
|
|||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
case SIGINT:
|
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)
|
std::exit(signum); // NOLINT(concurrency-mt-unsafe)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -32,6 +33,7 @@ int main()
|
|||||||
{
|
{
|
||||||
using fmt::format;
|
using fmt::format;
|
||||||
using std::cout;
|
using std::cout;
|
||||||
|
using std::endl;
|
||||||
using clock = std::chrono::system_clock;
|
using clock = std::chrono::system_clock;
|
||||||
using std::chrono::minutes;
|
using std::chrono::minutes;
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
@ -51,7 +53,7 @@ int main()
|
|||||||
R"({0:%Y-%m-%d} )"
|
R"({0:%Y-%m-%d} )"
|
||||||
R"(<span color="lightcyan">{0:%H:%M}</span>)",
|
R"(<span color="lightcyan">{0:%H:%M}</span>)",
|
||||||
now)
|
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)};
|
const auto next_minute{std::chrono::floor<minutes>(now + 1min)};
|
||||||
std::this_thread::sleep_until(next_minute);
|
std::this_thread::sleep_until(next_minute);
|
||||||
@ -59,7 +61,7 @@ int main()
|
|||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
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';
|
std::cerr << e.what() << '\n';
|
||||||
return 33;
|
return 33;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user