Skip to content

Commit

Permalink
self protection against flush for the backend worker thread
Browse files Browse the repository at this point in the history
block until the backend worker thread is spinning on start()
  • Loading branch information
odygrd committed May 12, 2020
1 parent 13d4bd7 commit 878c98a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
2 changes: 2 additions & 0 deletions quill/include/quill/Quill.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#pragma once

#include "quill/TweakMe.h"

#include "quill/detail/BackendWorker.h" // for backend_worker_error_h...
#include "quill/detail/LogMacros.h" // for filename_t
#include "quill/detail/LogManager.h" // for LogManager
Expand Down
1 change: 1 addition & 0 deletions quill/include/quill/QuillError.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#pragma once

#include "quill/TweakMe.h"

#include "quill/detail/misc/Macros.h"
#include <exception>
#include <string>
Expand Down
2 changes: 2 additions & 0 deletions quill/include/quill/detail/BackendWorker.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#pragma once

#include "quill/TweakMe.h"

#include "quill/QuillError.h" // for QUILL_CATCH, QUILL...
#include "quill/detail/BoundedSPSCQueue.h" // for BoundedSPSCQueue<>...
#include "quill/detail/Config.h" // for Config
Expand Down
2 changes: 2 additions & 0 deletions quill/include/quill/detail/LogManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#pragma once

#include "quill/TweakMe.h"

#include "quill/detail/BackendWorker.h"
#include "quill/detail/Config.h"
#include "quill/detail/HandlerCollection.h"
Expand Down
18 changes: 9 additions & 9 deletions quill/src/Quill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ void set_default_logger_handler(std::initializer_list<Handler*> handlers)
/***/
void flush() { detail::LogManagerSingleton::instance().log_manager().flush(); }

/***/
#if !defined(QUILL_NO_EXCEPTIONS)
void set_backend_worker_error_handler(backend_worker_error_handler_t backend_worker_error_handler)
{
detail::LogManagerSingleton::instance().log_manager().set_backend_worker_error_handler(
std::move(backend_worker_error_handler));
}
#endif

// ** Config ** //
namespace config
{
Expand All @@ -142,15 +151,6 @@ void set_backend_thread_sleep_duration(std::chrono::nanoseconds sleep_duration)
detail::LogManagerSingleton::instance().log_manager().config().set_backend_thread_sleep_duration(sleep_duration);
}

/***/
#if !defined(QUILL_NO_EXCEPTIONS)
void set_backend_worker_error_handler(backend_worker_error_handler_t backend_worker_error_handler)
{
detail::LogManagerSingleton::instance().log_manager().set_backend_worker_error_handler(
std::move(backend_worker_error_handler));
}
#endif

} // namespace config

} // namespace quill

0 comments on commit 878c98a

Please sign in to comment.