Commit 923e91c3 authored by Dominik Charousset's avatar Dominik Charousset

Log scoped and blocking actors too

parent 5a61e5da
...@@ -147,37 +147,38 @@ oss_wr operator<<(oss_wr&& lhs, T rhs) { ...@@ -147,37 +147,38 @@ oss_wr operator<<(oss_wr&& lhs, T rhs) {
#define CAF_LVL_NAME3() "DEBUG" #define CAF_LVL_NAME3() "DEBUG"
#define CAF_LVL_NAME4() "TRACE" #define CAF_LVL_NAME4() "TRACE"
#define CAF_PRINT_ERROR_IMPL(lvlname, classname, funname, message) \ #define CAF_PRINT_ERROR_IMPL(lvlname, classname, funname, message) \
{ \ { \
std::cerr << "[" << lvlname << "] " << classname << "::" << funname \ std::cerr << "[" << lvlname << "] " << classname << "::" << funname \
<< ": " << message << "\n"; \ << ": " << message << "\n"; \
} \ } \
CAF_VOID_STMT CAF_VOID_STMT
#ifndef CAF_LOG_LEVEL #ifndef CAF_LOG_LEVEL
inline caf::actor_id caf_set_aid_dummy() { return 0; } inline caf::actor_id caf_set_aid_dummy() { return 0; }
#define CAF_LOG_IMPL(lvlname, classname, funname, message) \ #define CAF_LOG_IMPL(lvlname, classname, funname, message) \
CAF_PRINT_ERROR_IMPL(lvlname, classname, funname, message) CAF_PRINT_ERROR_IMPL(lvlname, classname, funname, message)
#define CAF_PUSH_AID(unused) static_cast<void>(0) #define CAF_PUSH_AID(unused) static_cast<void>(0)
#define CAF_PUSH_AID_FROM_PTR(unused) static_cast<void>(0) #define CAF_PUSH_AID_FROM_PTR(unused) static_cast<void>(0)
#define CAF_SET_AID(unused) caf_set_aid_dummy() #define CAF_SET_AID(unused) caf_set_aid_dummy()
#else #else
#define CAF_LOG_IMPL(lvlname, classname, funname, message) \ #define CAF_LOG_IMPL(lvlname, classname, funname, message) \
if (strcmp(lvlname, "ERROR") == 0) { \ if (strcmp(lvlname, "ERROR") == 0) { \
CAF_PRINT_ERROR_IMPL(lvlname, classname, funname, message); \ CAF_PRINT_ERROR_IMPL(lvlname, classname, funname, message); \
} \ } \
caf::detail::singletons::get_logger()->log(lvlname, classname, funname, \ caf::detail::singletons::get_logger()->log(lvlname, classname, funname, \
__FILE__, __LINE__, \ __FILE__, __LINE__, \
(caf::detail::oss_wr{} \ (caf::detail::oss_wr{} \
<< message).str()) << std::boolalpha \
#define CAF_PUSH_AID(aid_arg) \ << message).str())
auto prev_aid_in_scope = \ #define CAF_PUSH_AID(aid_arg) \
caf::detail::singletons::get_logger()->set_aid(aid_arg); \ auto prev_aid_in_scope \
auto aid_pop_sg = caf::detail::make_scope_guard([=] { \ = caf::detail::singletons::get_logger()->set_aid(aid_arg); \
caf::detail::singletons::get_logger()->set_aid(prev_aid_in_scope); \ auto aid_pop_sg = caf::detail::make_scope_guard([=] { \
caf::detail::singletons::get_logger()->set_aid(prev_aid_in_scope); \
}) })
#define CAF_PUSH_AID_FROM_PTR(some_ptr) \ #define CAF_PUSH_AID_FROM_PTR(some_ptr) \
auto aid_ptr_argument = some_ptr; \ auto aid_ptr_argument = some_ptr; \
CAF_PUSH_AID(aid_ptr_argument ? aid_ptr_argument->id() : 0) CAF_PUSH_AID(aid_ptr_argument ? aid_ptr_argument->id() : 0)
#define CAF_SET_AID(aid_arg) \ #define CAF_SET_AID(aid_arg) \
caf::detail::singletons::get_logger()->set_aid(aid_arg) caf::detail::singletons::get_logger()->set_aid(aid_arg)
...@@ -185,28 +186,28 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; } ...@@ -185,28 +186,28 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; }
#define CAF_CLASS_NAME caf::detail::demangle(typeid(decltype(*this))).c_str() #define CAF_CLASS_NAME caf::detail::demangle(typeid(decltype(*this))).c_str()
#define CAF_PRINT0(lvlname, classname, funname, msg) \ #define CAF_PRINT0(lvlname, classname, funname, msg) \
CAF_LOG_IMPL(lvlname, classname, funname, msg) CAF_LOG_IMPL(lvlname, classname, funname, msg)
#define CAF_PRINT_IF0(stmt, lvlname, classname, funname, msg) \ #define CAF_PRINT_IF0(stmt, lvlname, classname, funname, msg) \
if (stmt) { \ if (stmt) { \
CAF_LOG_IMPL(lvlname, classname, funname, msg); \ CAF_LOG_IMPL(lvlname, classname, funname, msg); \
} \ } \
CAF_VOID_STMT CAF_VOID_STMT
#define CAF_PRINT1(lvlname, classname, funname, msg) \ #define CAF_PRINT1(lvlname, classname, funname, msg) \
CAF_PRINT0(lvlname, classname, funname, msg) CAF_PRINT0(lvlname, classname, funname, msg)
#define CAF_PRINT_IF1(stmt, lvlname, classname, funname, msg) \ #define CAF_PRINT_IF1(stmt, lvlname, classname, funname, msg) \
CAF_PRINT_IF0(stmt, lvlname, classname, funname, msg) CAF_PRINT_IF0(stmt, lvlname, classname, funname, msg)
#if CAF_LOG_LEVEL < CAF_TRACE #if CAF_LOG_LEVEL < CAF_TRACE
#define CAF_PRINT4(arg0, arg1, arg2, arg3) #define CAF_PRINT4(arg0, arg1, arg2, arg3)
#else #else
#define CAF_PRINT4(lvlname, classname, funname, msg) \ #define CAF_PRINT4(lvlname, classname, funname, msg) \
caf::detail::logging::trace_helper caf_trace_helper_ { \ caf::detail::logging::trace_helper caf_trace_helper_ { \
classname, funname, __FILE__, __LINE__, \ classname, funname, __FILE__, __LINE__, \
(caf::detail::oss_wr{} << msg).str() \ (caf::detail::oss_wr{} << msg).str() \
} }
#endif #endif
...@@ -214,9 +215,9 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; } ...@@ -214,9 +215,9 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; }
#define CAF_PRINT3(arg0, arg1, arg2, arg3) #define CAF_PRINT3(arg0, arg1, arg2, arg3)
#define CAF_PRINT_IF3(arg0, arg1, arg2, arg3, arg4) #define CAF_PRINT_IF3(arg0, arg1, arg2, arg3, arg4)
#else #else
#define CAF_PRINT3(lvlname, classname, funname, msg) \ #define CAF_PRINT3(lvlname, classname, funname, msg) \
CAF_PRINT0(lvlname, classname, funname, msg) CAF_PRINT0(lvlname, classname, funname, msg)
#define CAF_PRINT_IF3(stmt, lvlname, classname, funname, msg) \ #define CAF_PRINT_IF3(stmt, lvlname, classname, funname, msg) \
CAF_PRINT_IF0(stmt, lvlname, classname, funname, msg) CAF_PRINT_IF0(stmt, lvlname, classname, funname, msg)
#endif #endif
...@@ -224,9 +225,9 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; } ...@@ -224,9 +225,9 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; }
#define CAF_PRINT2(arg0, arg1, arg2, arg3) #define CAF_PRINT2(arg0, arg1, arg2, arg3)
#define CAF_PRINT_IF2(arg0, arg1, arg2, arg3, arg4) #define CAF_PRINT_IF2(arg0, arg1, arg2, arg3, arg4)
#else #else
#define CAF_PRINT2(lvlname, classname, funname, msg) \ #define CAF_PRINT2(lvlname, classname, funname, msg) \
CAF_PRINT0(lvlname, classname, funname, msg) CAF_PRINT0(lvlname, classname, funname, msg)
#define CAF_PRINT_IF2(stmt, lvlname, classname, funname, msg) \ #define CAF_PRINT_IF2(stmt, lvlname, classname, funname, msg) \
CAF_PRINT_IF0(stmt, lvlname, classname, funname, msg) CAF_PRINT_IF0(stmt, lvlname, classname, funname, msg)
#endif #endif
...@@ -236,9 +237,9 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; } ...@@ -236,9 +237,9 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; }
* @def CAF_LOGC * @def CAF_LOGC
* Logs a message with custom class and function names. * Logs a message with custom class and function names.
*/ */
#define CAF_LOGC(level, classname, funname, msg) \ #define CAF_LOGC(level, classname, funname, msg) \
CAF_CAT(CAF_PRINT, level)(CAF_CAT(CAF_LVL_NAME, level)(), classname, \ CAF_CAT(CAF_PRINT, level)(CAF_CAT(CAF_LVL_NAME, level)(), classname, \
funname, msg) funname, msg)
/** /**
* @def CAF_LOGF * @def CAF_LOGF
...@@ -256,22 +257,22 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; } ...@@ -256,22 +257,22 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; }
* @def CAF_LOGC * @def CAF_LOGC
* Logs a message with custom class and function names. * Logs a message with custom class and function names.
*/ */
#define CAF_LOGC_IF(stmt, level, classname, funname, msg) \ #define CAF_LOGC_IF(stmt, level, classname, funname, msg) \
CAF_CAT(CAF_PRINT_IF, level)(stmt, CAF_CAT(CAF_LVL_NAME, level)(), \ CAF_CAT(CAF_PRINT_IF, level)(stmt, CAF_CAT(CAF_LVL_NAME, level)(), \
classname, funname, msg) classname, funname, msg)
/** /**
* @def CAF_LOGF * @def CAF_LOGF
* Logs a message inside a free function. * Logs a message inside a free function.
*/ */
#define CAF_LOGF_IF(stmt, level, msg) \ #define CAF_LOGF_IF(stmt, level, msg) \
CAF_LOGC_IF(stmt, level, "NONE", __func__, msg) CAF_LOGC_IF(stmt, level, "NONE", __func__, msg)
/** /**
* @def CAF_LOGMF * @def CAF_LOGMF
* Logs a message inside a member function. * Logs a message inside a member function.
*/ */
#define CAF_LOGMF_IF(stmt, level, msg) \ #define CAF_LOGMF_IF(stmt, level, msg) \
CAF_LOGC_IF(stmt, level, CAF_CLASS_NAME, __func__, msg) CAF_LOGC_IF(stmt, level, CAF_CLASS_NAME, __func__, msg)
// convenience macros to safe some typing when printing arguments // convenience macros to safe some typing when printing arguments
...@@ -281,7 +282,7 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; } ...@@ -281,7 +282,7 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; }
#define CAF_TSARG(arg) #arg << " = " << to_string(arg) #define CAF_TSARG(arg) #arg << " = " << to_string(arg)
/****************************************************************************** /******************************************************************************
* convenience macros * * convenience macros *
******************************************************************************/ ******************************************************************************/
#define CAF_LOG_ERROR(msg) CAF_LOGMF(CAF_ERROR, msg) #define CAF_LOG_ERROR(msg) CAF_LOGMF(CAF_ERROR, msg)
...@@ -296,35 +297,30 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; } ...@@ -296,35 +297,30 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; }
#define CAF_LOG_INFO_IF(stmt, msg) CAF_LOGMF_IF(stmt, CAF_INFO, msg) #define CAF_LOG_INFO_IF(stmt, msg) CAF_LOGMF_IF(stmt, CAF_INFO, msg)
#define CAF_LOG_TRACE_IF(stmt, msg) CAF_LOGMF_IF(stmt, CAF_TRACE, msg) #define CAF_LOG_TRACE_IF(stmt, msg) CAF_LOGMF_IF(stmt, CAF_TRACE, msg)
#define CAF_LOGC_ERROR(cname, fname, msg) \ #define CAF_LOGC_ERROR(cname, fun, msg) CAF_LOGC(CAF_ERROR, cname, fun, msg)
CAF_LOGC(CAF_ERROR, cname, fname, msg)
#define CAF_LOGC_WARNING(cname, fname, msg) \ #define CAF_LOGC_WARNING(cname, fun, msg) CAF_LOGC(CAF_WARNING, cname, fun, msg)
CAF_LOGC(CAF_WARNING, cname, fname, msg)
#define CAF_LOGC_DEBUG(cname, fname, msg) \ #define CAF_LOGC_DEBUG(cname, fun, msg) CAF_LOGC(CAF_DEBUG, cname, fun, msg)
CAF_LOGC(CAF_DEBUG, cname, fname, msg)
#define CAF_LOGC_INFO(cname, fname, msg) \ #define CAF_LOGC_INFO(cname, fun, msg) CAF_LOGC(CAF_INFO, cname, fun, msg)
CAF_LOGC(CAF_INFO, cname, fname, msg)
#define CAF_LOGC_TRACE(cname, fname, msg) \ #define CAF_LOGC_TRACE(cname, fun, msg) CAF_LOGC(CAF_TRACE, cname, fun, msg)
CAF_LOGC(CAF_TRACE, cname, fname, msg)
#define CAF_LOGC_ERROR_IF(stmt, cname, fname, msg) \ #define CAF_LOGC_ERROR_IF(stmt, cname, fun, msg) \
CAF_LOGC_IF(stmt, CAF_ERROR, cname, fname, msg) CAF_LOGC_IF(stmt, CAF_ERROR, cname, fun, msg)
#define CAF_LOGC_WARNING_IF(stmt, cname, fname, msg) \ #define CAF_LOGC_WARNING_IF(stmt, cname, fun, msg) \
CAF_LOGC_IF(stmt, CAF_WARNING, cname, fname, msg) CAF_LOGC_IF(stmt, CAF_WARNING, cname, fun, msg)
#define CAF_LOGC_DEBUG_IF(stmt, cname, fname, msg) \ #define CAF_LOGC_DEBUG_IF(stmt, cname, fun, msg) \
CAF_LOGC_IF(stmt, CAF_DEBUG, cname, fname, msg) CAF_LOGC_IF(stmt, CAF_DEBUG, cname, fun, msg)
#define CAF_LOGC_INFO_IF(stmt, cname, fname, msg) \ #define CAF_LOGC_INFO_IF(stmt, cname, fun, msg) \
CAF_LOGC_IF(stmt, CAF_INFO, cname, fname, msg) CAF_LOGC_IF(stmt, CAF_INFO, cname, fun, msg)
#define CAF_LOGC_TRACE_IF(stmt, cname, fname, msg) \ #define CAF_LOGC_TRACE_IF(stmt, cname, fun, msg) \
CAF_LOGC_IF(stmt, CAF_TRACE, cname, fname, msg) CAF_LOGC_IF(stmt, CAF_TRACE, cname, fun, msg)
#define CAF_LOGF_ERROR(msg) CAF_LOGF(CAF_ERROR, msg) #define CAF_LOGF_ERROR(msg) CAF_LOGF(CAF_ERROR, msg)
#define CAF_LOGF_WARNING(msg) CAF_LOGF(CAF_WARNING, msg) #define CAF_LOGF_WARNING(msg) CAF_LOGF(CAF_WARNING, msg)
...@@ -348,19 +344,19 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; } ...@@ -348,19 +344,19 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; }
#define CAF_LOGM_TRACE(cname, msg) CAF_LOGC(CAF_TRACE, cname, __func__, msg) #define CAF_LOGM_TRACE(cname, msg) CAF_LOGC(CAF_TRACE, cname, __func__, msg)
#define CAF_LOGM_ERROR_IF(stmt, cname, msg) \ #define CAF_LOGM_ERROR_IF(stmt, cname, msg) \
CAF_LOGC_IF(stmt, CAF_ERROR, cname, __func__, msg) CAF_LOGC_IF(stmt, CAF_ERROR, cname, __func__, msg)
#define CAF_LOGM_WARNING_IF(stmt, cname, msg) \ #define CAF_LOGM_WARNING_IF(stmt, cname, msg) \
CAF_LOGC_IF(stmt, CAF_WARNING, cname, msg) CAF_LOGC_IF(stmt, CAF_WARNING, cname, msg)
#define CAF_LOGM_DEBUG_IF(stmt, cname, msg) \ #define CAF_LOGM_DEBUG_IF(stmt, cname, msg) \
CAF_LOGC_IF(stmt, CAF_DEBUG, cname, __func__, msg) CAF_LOGC_IF(stmt, CAF_DEBUG, cname, __func__, msg)
#define CAF_LOGM_INFO_IF(stmt, cname, msg) \ #define CAF_LOGM_INFO_IF(stmt, cname, msg) \
CAF_LOGC_IF(stmt, CAF_INFO, cname, __func__, msg) CAF_LOGC_IF(stmt, CAF_INFO, cname, __func__, msg)
#define CAF_LOGM_TRACE_IF(stmt, cname, msg) \ #define CAF_LOGM_TRACE_IF(stmt, cname, msg) \
CAF_LOGC_IF(stmt, CAF_TRACE, cname, __func__, msg) CAF_LOGC_IF(stmt, CAF_TRACE, cname, __func__, msg)
#endif // CAF_LOGGING_HPP #endif // CAF_LOGGING_HPP
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include "caf/mixin/memory_cached.hpp" #include "caf/mixin/memory_cached.hpp"
#include "caf/detail/logging.hpp"
#include "caf/detail/behavior_stack.hpp" #include "caf/detail/behavior_stack.hpp"
#include "caf/detail/typed_actor_util.hpp" #include "caf/detail/typed_actor_util.hpp"
#include "caf/detail/single_reader_queue.hpp" #include "caf/detail/single_reader_queue.hpp"
......
...@@ -61,8 +61,8 @@ class event_based_resume { ...@@ -61,8 +61,8 @@ class event_based_resume {
size_t max_throughput) override { size_t max_throughput) override {
CAF_REQUIRE(max_throughput > 0); CAF_REQUIRE(max_throughput > 0);
auto d = static_cast<Derived*>(this); auto d = static_cast<Derived*>(this);
d->host(new_host);
CAF_LOG_TRACE("id = " << d->id()); CAF_LOG_TRACE("id = " << d->id());
d->host(new_host);
auto done_cb = [&]() -> bool { auto done_cb = [&]() -> bool {
CAF_LOG_TRACE(""); CAF_LOG_TRACE("");
d->bhvr_stack().clear(); d->bhvr_stack().clear();
......
...@@ -89,6 +89,7 @@ class invoke_policy { ...@@ -89,6 +89,7 @@ class invoke_policy {
if (!node_ptr) { if (!node_ptr) {
return false; return false;
} }
CAF_LOG_TRACE("");
switch (handle_message(self, node_ptr.get(), fun, awaited_response)) { switch (handle_message(self, node_ptr.get(), fun, awaited_response)) {
case hm_msg_handled: case hm_msg_handled:
node_ptr.reset(); node_ptr.reset();
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "caf/exception.hpp" #include "caf/exception.hpp"
#include "caf/exit_reason.hpp" #include "caf/exit_reason.hpp"
#include "caf/detail/logging.hpp"
#include "caf/policy/resume_policy.hpp" #include "caf/policy/resume_policy.hpp"
namespace caf { namespace caf {
...@@ -29,6 +30,7 @@ class no_resume { ...@@ -29,6 +30,7 @@ class no_resume {
} }
resumable::resume_result resume(execution_unit*, size_t) { resumable::resume_result resume(execution_unit*, size_t) {
CAF_LOG_TRACE("");
uint32_t rsn = exit_reason::normal; uint32_t rsn = exit_reason::normal;
try { try {
this->act(); this->act();
......
...@@ -34,7 +34,9 @@ namespace caf { ...@@ -34,7 +34,9 @@ namespace caf {
namespace { namespace {
struct impl : blocking_actor { struct impl : blocking_actor {
void act() override {} void act() override {
CAF_LOG_ERROR("act() of scoped_actor impl called");
}
}; };
blocking_actor* alloc() { blocking_actor* alloc() {
...@@ -48,10 +50,11 @@ blocking_actor* alloc() { ...@@ -48,10 +50,11 @@ blocking_actor* alloc() {
void scoped_actor::init(bool hide_actor) { void scoped_actor::init(bool hide_actor) {
m_self.reset(alloc()); m_self.reset(alloc());
m_self->is_registered(!hide_actor);
if (!hide_actor) { if (!hide_actor) {
m_prev = CAF_SET_AID(m_self->id()); m_prev = CAF_SET_AID(m_self->id());
} }
CAF_LOG_TRACE(CAF_ARG(hide_actor));
m_self->is_registered(!hide_actor);
} }
scoped_actor::scoped_actor() { scoped_actor::scoped_actor() {
...@@ -63,6 +66,7 @@ scoped_actor::scoped_actor(bool hide_actor) { ...@@ -63,6 +66,7 @@ scoped_actor::scoped_actor(bool hide_actor) {
} }
scoped_actor::~scoped_actor() { scoped_actor::~scoped_actor() {
CAF_LOG_TRACE("");
if (m_self->is_registered()) { if (m_self->is_registered()) {
CAF_SET_AID(m_prev); CAF_SET_AID(m_prev);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment