Commit e96c0df0 authored by Dominik Charousset's avatar Dominik Charousset

Improve logging of SE-0001 events

parent a32890db
......@@ -51,6 +51,8 @@ public:
static constexpr int is_actor_decorator_mask = 0x0C000000;
static constexpr int is_hidden_flag = 0x10000000;
inline bool is_abstract_actor() const {
return static_cast<bool>(flags() & is_abstract_actor_flag);
}
......
......@@ -532,6 +532,8 @@ private:
: 0;
if (has_detach_flag(Os) || std::is_base_of<blocking_actor, C>::value)
cfg.flags |= abstract_actor::is_detached_flag;
if (has_hide_flag(Os))
cfg.flags |= abstract_actor::is_hidden_flag;
if (!cfg.host)
cfg.host = dummy_execution_unit();
CAF_SET_LOGGER_SYS(this);
......
......@@ -39,6 +39,7 @@
#include "caf/detail/scope_guard.hpp"
#include "caf/detail/shared_spinlock.hpp"
#include "caf/detail/pretty_type_name.hpp"
#include "caf/detail/single_reader_queue.hpp"
/*
......@@ -423,10 +424,13 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; }
/// crucial for understanding happens-before relations. See RFC SE-0001.
#define CAF_LOG_FLOW_COMPONENT "caf.flow"
#define CAF_LOG_SPAWN_EVENT(aid, aargs) \
#define CAF_LOG_SPAWN_EVENT(ref, ctor_data) \
CAF_LOG_IMPL(CAF_LOG_FLOW_COMPONENT, CAF_LOG_LEVEL_DEBUG, \
"SPAWN ; ID =" << aid \
<< "; ARGS =" << deep_to_string(aargs).c_str())
"SPAWN ; ID =" << ref.id() << "; NAME =" << ref.name() \
<< "; TYPE =" \
<< ::caf::detail::pretty_type_name(typeid(ref)) \
<< "; ARGS =" << ctor_data.c_str() \
<< "; NODE =" << ref.node())
#define CAF_LOG_INIT_EVENT(aName, aHide) \
CAF_LOG_IMPL(CAF_LOG_FLOW_COMPONENT, CAF_LOG_LEVEL_DEBUG, \
......@@ -462,8 +466,11 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; }
#define CAF_LOG_FINALIZE_EVENT() \
CAF_LOG_IMPL(CAF_LOG_FLOW_COMPONENT, CAF_LOG_LEVEL_DEBUG, "FINALIZE")
#define CAF_LOG_TERMINATE_EVENT(rsn) \
#define CAF_LOG_TERMINATE_EVENT(thisptr, rsn) \
CAF_LOG_IMPL(CAF_LOG_FLOW_COMPONENT, CAF_LOG_LEVEL_DEBUG, \
"TERMINATE ; REASON =" << deep_to_string(rsn).c_str())
"TERMINATE ; ID =" \
<< thisptr->id() << "; NAME =" << thisptr->name() \
<< "; REASON =" << deep_to_string(rsn).c_str() \
<< "; NODE =" << thisptr->node())
#endif // CAF_LOGGER_HPP
......@@ -34,9 +34,23 @@ namespace caf {
template <class T, class R = infer_handle_from_class_t<T>, class... Ts>
R make_actor(actor_id aid, node_id nid, actor_system* sys, Ts&&... xs) {
CAF_LOG_SPAWN_EVENT(aid, std::forward_as_tuple(xs...));
#if defined(CAF_LOG_LEVEL) && CAF_LOG_LEVEL >= CAF_LOG_LEVEL_DEBUG
actor_storage<T>* ptr = nullptr;
if (logger::current_logger()->accepts(CAF_LOG_LEVEL_DEBUG,
CAF_LOG_FLOW_COMPONENT)) {
std::string args;
args = deep_to_string(std::forward_as_tuple(xs...));
ptr = new actor_storage<T>(aid, std::move(nid), sys,
std::forward<Ts>(xs)...);
CAF_LOG_SPAWN_EVENT(ptr->data, args);
} else {
ptr = new actor_storage<T>(aid, std::move(nid), sys,
std::forward<Ts>(xs)...);
}
#else
auto ptr = new actor_storage<T>(aid, std::move(nid), sys,
std::forward<Ts>(xs)...);
#endif
return {&(ptr->ctrl), false};
}
......
......@@ -186,7 +186,7 @@ bool local_actor::cleanup(error&& fail_state, execution_unit* host) {
// tell registry we're done
unregister_from_system();
monitorable_actor::cleanup(std::move(fail_state), host);
CAF_LOG_TERMINATE_EVENT(fail_state);
CAF_LOG_TERMINATE_EVENT(this, fail_state);
return true;
}
......
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