Skip to content

Commit

Permalink
Merge pull request #398 from evoskuil/master
Browse files Browse the repository at this point in the history
Add logger.stopped().
  • Loading branch information
evoskuil committed May 9, 2024
2 parents cddeec3 + b679d77 commit ae2523c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/bitcoin/network/log/logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class BCT_API logger final
void stop(const code& ec, const std::string& message, uint8_t level) NOEXCEPT;
void stop(const std::string& message, uint8_t level=levels::quit) NOEXCEPT;
void stop(uint8_t level=levels::quit) NOEXCEPT;
bool stopped() const NOEXCEPT;

protected:
bool stranded() const NOEXCEPT;
Expand Down
9 changes: 7 additions & 2 deletions src/log/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ void logger::stop(const code& ec, const std::string& message,
this, ec, zulu_time(), message, level));
}

bool logger::stopped() const NOEXCEPT
{
return stopped_.load();
}

// private
void logger::do_stop(const code& ec, time_t zulu, const std::string& message,
uint8_t level) NOEXCEPT
Expand Down Expand Up @@ -117,7 +122,7 @@ void logger::do_notify_message(const code& ec, uint8_t level, time_t zulu,

void logger::subscribe_messages(message_notifier&& handler) NOEXCEPT
{
if (stopped_.load())
if (stopped())
{
handler(error::service_stopped, {}, {}, {});
return;
Expand Down Expand Up @@ -161,7 +166,7 @@ void logger::do_notify_event(uint8_t event_, uint64_t value,

void logger::subscribe_events(event_notifier&& handler) NOEXCEPT
{
if (stopped_.load())
if (stopped())
{
handler(error::service_stopped, {}, {}, {});
return;
Expand Down

0 comments on commit ae2523c

Please sign in to comment.