Skip to content

Commit

Permalink
Merge pull request #623 from evoskuil/master
Browse files Browse the repository at this point in the history
Guard subscriber from invalid log levels and emit.
  • Loading branch information
evoskuil authored May 15, 2024
2 parents cd9276e + 45aba55 commit 5dd3813
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions console/executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2378,6 +2378,14 @@ void executor::subscribe_log(std::ostream& sink)
log_.subscribe_messages([&](const code& ec, uint8_t level, time_t time,
const std::string& message)
{
if (level >= toggle_.size())
{
sink << "Invalid log [" << serialize(level) << "] : " << message;
output_ << "Invalid log [" << serialize(level) << "] : " << message;
output_.flush();
return true;
}

// Write only selected logs.
if (!ec && !toggle_.at(level))
return true;
Expand Down

0 comments on commit 5dd3813

Please sign in to comment.