Skip to content

Commit

Permalink
Periodic log flushing
Browse files Browse the repository at this point in the history
Fix some compile Wreorder warnings.
  • Loading branch information
SemaiCZE committed Feb 20, 2017
1 parent a46fd2f commit 67bb472
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion recodex-broker.spec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
Prefix: %{_prefix}
Vendor: Petr Stefan <UNKNOWN>
Url: https://github.com/ReCodEx/broker
BuildRequires: systemd cmake
BuildRequires: systemd cmake zeromq-devel cppzmq-devel yaml-cpp-devel libcurl-devel spdlog-devel
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
Expand Down
4 changes: 2 additions & 2 deletions src/broker_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ void broker_core::log_init()
log_conf.log_suffix,
log_conf.log_file_size,
log_conf.log_files_count);
// Set queue size for asynchronous logging. It must be a power of 2.
spdlog::set_async_mode(1048576);
// Set queue size for asynchronous logging. It must be a power of 2. Also, flush every 2 seconds.
spdlog::set_async_mode(1048576, spdlog::async_overflow_policy::block_retry, nullptr, std::chrono::seconds(2));
// Make log with name "logger"
logger_ = std::make_shared<spdlog::logger>("logger", rotating_sink);
// Set logging level to debug
Expand Down
4 changes: 3 additions & 1 deletion src/handlers/broker_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,9 @@ void broker_handler::process_worker_done(

if (message.at(1) != current->data.get_job_id()) {
logger_->error("Got 'done' message from worker {} with mismatched job id - {} (message) vs. {} (worker)",
worker->get_description(), message.at(1), current->data.get_job_id());
worker->get_description(),
message.at(1),
current->data.get_job_id());
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class count_matcher : public header_matcher
* Constructor.
* @param my_value Base value for comparison. Will be converted to @a size_t type using std::stoul.
*/
count_matcher(std::string my_value) : my_count_(std::stoul(my_value)), header_matcher(my_value)
count_matcher(std::string my_value) : header_matcher(my_value), my_count_(std::stoul(my_value))
{
}

Expand All @@ -88,7 +88,7 @@ class count_matcher : public header_matcher

worker::worker(
const std::string &id, const std::string &hwgroup, const std::multimap<std::string, std::string> &headers)
: identity(id), hwgroup(hwgroup), free_(true), current_request_(nullptr), headers_copy_(headers)
: headers_copy_(headers), free_(true), current_request_(nullptr), identity(id), hwgroup(hwgroup)
{
headers_.emplace("hwgroup", std::unique_ptr<header_matcher>(new multiple_string_matcher(hwgroup)));

Expand Down

0 comments on commit 67bb472

Please sign in to comment.