Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
923e91c3
Commit
923e91c3
authored
Sep 11, 2014
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Log scoped and blocking actors too
parent
5a61e5da
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
77 additions
and
73 deletions
+77
-73
libcaf_core/caf/detail/logging.hpp
libcaf_core/caf/detail/logging.hpp
+66
-70
libcaf_core/caf/local_actor.hpp
libcaf_core/caf/local_actor.hpp
+1
-0
libcaf_core/caf/policy/event_based_resume.hpp
libcaf_core/caf/policy/event_based_resume.hpp
+1
-1
libcaf_core/caf/policy/invoke_policy.hpp
libcaf_core/caf/policy/invoke_policy.hpp
+1
-0
libcaf_core/caf/policy/no_resume.hpp
libcaf_core/caf/policy/no_resume.hpp
+2
-0
libcaf_core/src/scoped_actor.cpp
libcaf_core/src/scoped_actor.cpp
+6
-2
No files found.
libcaf_core/caf/detail/logging.hpp
View file @
923e91c3
...
...
@@ -147,37 +147,38 @@ oss_wr operator<<(oss_wr&& lhs, T rhs) {
#define CAF_LVL_NAME3() "DEBUG"
#define CAF_LVL_NAME4() "TRACE"
#define CAF_PRINT_ERROR_IMPL(lvlname, classname, funname, message) \
{ \
std::cerr << "[" << lvlname << "] " << classname << "::" << funname \
<< ": " << message << "\n";
\
} \
#define CAF_PRINT_ERROR_IMPL(lvlname, classname, funname, message)
\
{
\
std::cerr << "[" << lvlname << "] " << classname << "::" << funname
\
<< ": " << message << "\n";
\
}
\
CAF_VOID_STMT
#ifndef CAF_LOG_LEVEL
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)
#define CAF_PUSH_AID(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()
#else
#define CAF_LOG_IMPL(lvlname, classname, funname, message) \
if (strcmp(lvlname, "ERROR") == 0) { \
CAF_PRINT_ERROR_IMPL(lvlname, classname, funname, message); \
} \
caf::detail::singletons::get_logger()->log(lvlname, classname, funname, \
__FILE__, __LINE__, \
(caf::detail::oss_wr{} \
<< message).str())
#define CAF_PUSH_AID(aid_arg) \
auto prev_aid_in_scope = \
caf::detail::singletons::get_logger()->set_aid(aid_arg); \
auto aid_pop_sg = caf::detail::make_scope_guard([=] { \
caf::detail::singletons::get_logger()->set_aid(prev_aid_in_scope); \
#define CAF_LOG_IMPL(lvlname, classname, funname, message) \
if (strcmp(lvlname, "ERROR") == 0) { \
CAF_PRINT_ERROR_IMPL(lvlname, classname, funname, message); \
} \
caf::detail::singletons::get_logger()->log(lvlname, classname, funname, \
__FILE__, __LINE__, \
(caf::detail::oss_wr{} \
<< std::boolalpha \
<< message).str())
#define CAF_PUSH_AID(aid_arg) \
auto prev_aid_in_scope \
= caf::detail::singletons::get_logger()->set_aid(aid_arg); \
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) \
auto aid_ptr_argument = some_ptr; \
#define CAF_PUSH_AID_FROM_PTR(some_ptr)
\
auto aid_ptr_argument = some_ptr;
\
CAF_PUSH_AID(aid_ptr_argument ? aid_ptr_argument->id() : 0)
#define CAF_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; }
#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)
#define CAF_PRINT_IF0(stmt, lvlname, classname, funname, msg) \
if (stmt) { \
CAF_LOG_IMPL(lvlname, classname, funname, msg); \
} \
#define CAF_PRINT_IF0(stmt, lvlname, classname, funname, msg)
\
if (stmt) {
\
CAF_LOG_IMPL(lvlname, classname, funname, msg);
\
}
\
CAF_VOID_STMT
#define CAF_PRINT1(lvlname, classname, funname, msg) \
#define CAF_PRINT1(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)
#if CAF_LOG_LEVEL < CAF_TRACE
#define CAF_PRINT4(arg0, arg1, arg2, arg3)
#else
#define CAF_PRINT4(lvlname, classname, funname, msg) \
caf::detail::logging::trace_helper caf_trace_helper_ { \
classname, funname, __FILE__, __LINE__, \
(caf::detail::oss_wr{} << msg).str() \
#define CAF_PRINT4(lvlname, classname, funname, msg)
\
caf::detail::logging::trace_helper caf_trace_helper_ {
\
classname, funname, __FILE__, __LINE__,
\
(caf::detail::oss_wr{} << msg).str()
\
}
#endif
...
...
@@ -214,9 +215,9 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; }
#define CAF_PRINT3(arg0, arg1, arg2, arg3)
#define CAF_PRINT_IF3(arg0, arg1, arg2, arg3, arg4)
#else
#define CAF_PRINT3(lvlname, classname, funname, msg) \
#define CAF_PRINT3(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)
#endif
...
...
@@ -224,9 +225,9 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; }
#define CAF_PRINT2(arg0, arg1, arg2, arg3)
#define CAF_PRINT_IF2(arg0, arg1, arg2, arg3, arg4)
#else
#define CAF_PRINT2(lvlname, classname, funname, msg) \
#define CAF_PRINT2(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)
#endif
...
...
@@ -236,9 +237,9 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; }
* @def CAF_LOGC
* Logs a message with custom class and function names.
*/
#define CAF_LOGC(level, classname, funname, msg) \
CAF_CAT(CAF_PRINT, level)(CAF_CAT(CAF_LVL_NAME, level)(), classname, \
funname, msg)
#define CAF_LOGC(level, classname, funname, msg)
\
CAF_CAT(CAF_PRINT, level)(CAF_CAT(CAF_LVL_NAME, level)(), classname,
\
funname, msg)
/**
* @def CAF_LOGF
...
...
@@ -256,22 +257,22 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; }
* @def CAF_LOGC
* Logs a message with custom class and function names.
*/
#define CAF_LOGC_IF(stmt, level, classname, funname, msg) \
CAF_CAT(CAF_PRINT_IF, level)(stmt, CAF_CAT(CAF_LVL_NAME, 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)(),
\
classname, funname, msg)
/**
* @def CAF_LOGF
* 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)
/**
* @def CAF_LOGMF
* 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)
// convenience macros to safe some typing when printing arguments
...
...
@@ -281,7 +282,7 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; }
#define CAF_TSARG(arg) #arg << " = " << to_string(arg)
/******************************************************************************
*
convenience macros
*
*
convenience macros
*
******************************************************************************/
#define CAF_LOG_ERROR(msg) CAF_LOGMF(CAF_ERROR, msg)
...
...
@@ -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_TRACE_IF(stmt, msg) CAF_LOGMF_IF(stmt, CAF_TRACE, msg)
#define CAF_LOGC_ERROR(cname, fname, msg) \
CAF_LOGC(CAF_ERROR, cname, fname, msg)
#define CAF_LOGC_ERROR(cname, fun, msg) CAF_LOGC(CAF_ERROR, cname, fun, msg)
#define CAF_LOGC_WARNING(cname, fname, msg) \
CAF_LOGC(CAF_WARNING, cname, fname, msg)
#define CAF_LOGC_WARNING(cname, fun, msg) CAF_LOGC(CAF_WARNING, cname, fun, msg)
#define CAF_LOGC_DEBUG(cname, fname, msg) \
CAF_LOGC(CAF_DEBUG, cname, fname, msg)
#define CAF_LOGC_DEBUG(cname, fun, msg) CAF_LOGC(CAF_DEBUG, cname, fun, msg)
#define CAF_LOGC_INFO(cname, fname, msg) \
CAF_LOGC(CAF_INFO, cname, fname, msg)
#define CAF_LOGC_INFO(cname, fun, msg) CAF_LOGC(CAF_INFO, cname, fun, msg)
#define CAF_LOGC_TRACE(cname, fname, msg) \
CAF_LOGC(CAF_TRACE, cname, fname, msg)
#define CAF_LOGC_TRACE(cname, fun, msg) CAF_LOGC(CAF_TRACE, cname, fun, msg)
#define CAF_LOGC_ERROR_IF(stmt, cname, f
name, msg)
\
CAF_LOGC_IF(stmt, CAF_ERROR, cname, f
name
, msg)
#define CAF_LOGC_ERROR_IF(stmt, cname, f
un, msg)
\
CAF_LOGC_IF(stmt, CAF_ERROR, cname, f
un
, msg)
#define CAF_LOGC_WARNING_IF(stmt, cname, f
name, msg)
\
CAF_LOGC_IF(stmt, CAF_WARNING, cname, f
name
, msg)
#define CAF_LOGC_WARNING_IF(stmt, cname, f
un, msg)
\
CAF_LOGC_IF(stmt, CAF_WARNING, cname, f
un
, msg)
#define CAF_LOGC_DEBUG_IF(stmt, cname, f
name, msg)
\
CAF_LOGC_IF(stmt, CAF_DEBUG, cname, f
name
, msg)
#define CAF_LOGC_DEBUG_IF(stmt, cname, f
un, msg)
\
CAF_LOGC_IF(stmt, CAF_DEBUG, cname, f
un
, msg)
#define CAF_LOGC_INFO_IF(stmt, cname, f
name, msg)
\
CAF_LOGC_IF(stmt, CAF_INFO, cname, f
name
, msg)
#define CAF_LOGC_INFO_IF(stmt, cname, f
un, msg)
\
CAF_LOGC_IF(stmt, CAF_INFO, cname, f
un
, msg)
#define CAF_LOGC_TRACE_IF(stmt, cname, f
name, msg)
\
CAF_LOGC_IF(stmt, CAF_TRACE, cname, f
name
, msg)
#define CAF_LOGC_TRACE_IF(stmt, cname, f
un, msg)
\
CAF_LOGC_IF(stmt, CAF_TRACE, cname, f
un
, msg)
#define CAF_LOGF_ERROR(msg) CAF_LOGF(CAF_ERROR, 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; }
#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)
#define CAF_LOGM_WARNING_IF(stmt, cname, msg) \
#define CAF_LOGM_WARNING_IF(stmt, 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)
#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)
#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)
#endif // CAF_LOGGING_HPP
libcaf_core/caf/local_actor.hpp
View file @
923e91c3
...
...
@@ -47,6 +47,7 @@
#include "caf/mixin/memory_cached.hpp"
#include "caf/detail/logging.hpp"
#include "caf/detail/behavior_stack.hpp"
#include "caf/detail/typed_actor_util.hpp"
#include "caf/detail/single_reader_queue.hpp"
...
...
libcaf_core/caf/policy/event_based_resume.hpp
View file @
923e91c3
...
...
@@ -61,8 +61,8 @@ class event_based_resume {
size_t
max_throughput
)
override
{
CAF_REQUIRE
(
max_throughput
>
0
);
auto
d
=
static_cast
<
Derived
*>
(
this
);
d
->
host
(
new_host
);
CAF_LOG_TRACE
(
"id = "
<<
d
->
id
());
d
->
host
(
new_host
);
auto
done_cb
=
[
&
]()
->
bool
{
CAF_LOG_TRACE
(
""
);
d
->
bhvr_stack
().
clear
();
...
...
libcaf_core/caf/policy/invoke_policy.hpp
View file @
923e91c3
...
...
@@ -89,6 +89,7 @@ class invoke_policy {
if
(
!
node_ptr
)
{
return
false
;
}
CAF_LOG_TRACE
(
""
);
switch
(
handle_message
(
self
,
node_ptr
.
get
(),
fun
,
awaited_response
))
{
case
hm_msg_handled
:
node_ptr
.
reset
();
...
...
libcaf_core/caf/policy/no_resume.hpp
View file @
923e91c3
...
...
@@ -6,6 +6,7 @@
#include "caf/exception.hpp"
#include "caf/exit_reason.hpp"
#include "caf/detail/logging.hpp"
#include "caf/policy/resume_policy.hpp"
namespace
caf
{
...
...
@@ -29,6 +30,7 @@ class no_resume {
}
resumable
::
resume_result
resume
(
execution_unit
*
,
size_t
)
{
CAF_LOG_TRACE
(
""
);
uint32_t
rsn
=
exit_reason
::
normal
;
try
{
this
->
act
();
...
...
libcaf_core/src/scoped_actor.cpp
View file @
923e91c3
...
...
@@ -34,7 +34,9 @@ namespace caf {
namespace
{
struct
impl
:
blocking_actor
{
void
act
()
override
{}
void
act
()
override
{
CAF_LOG_ERROR
(
"act() of scoped_actor impl called"
);
}
};
blocking_actor
*
alloc
()
{
...
...
@@ -48,10 +50,11 @@ blocking_actor* alloc() {
void
scoped_actor
::
init
(
bool
hide_actor
)
{
m_self
.
reset
(
alloc
());
m_self
->
is_registered
(
!
hide_actor
);
if
(
!
hide_actor
)
{
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
()
{
...
...
@@ -63,6 +66,7 @@ scoped_actor::scoped_actor(bool hide_actor) {
}
scoped_actor
::~
scoped_actor
()
{
CAF_LOG_TRACE
(
""
);
if
(
m_self
->
is_registered
())
{
CAF_SET_AID
(
m_prev
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment