Commit 41d3df49 authored by Dominik Charousset's avatar Dominik Charousset

Apply clang-format to logger.hpp

parent 656499e5
...@@ -18,13 +18,13 @@ ...@@ -18,13 +18,13 @@
#pragma once #pragma once
#include <thread>
#include <fstream>
#include <cstring> #include <cstring>
#include <sstream> #include <fstream>
#include <iostream> #include <iostream>
#include <typeinfo> #include <sstream>
#include <thread>
#include <type_traits> #include <type_traits>
#include <typeinfo>
#include <unordered_map> #include <unordered_map>
#include "caf/abstract_actor.hpp" #include "caf/abstract_actor.hpp"
...@@ -282,22 +282,20 @@ public: ...@@ -282,22 +282,20 @@ public:
/// Returns a string representation of the joined groups of `x` if `x` is an /// Returns a string representation of the joined groups of `x` if `x` is an
/// actor with the `subscriber` mixin. /// actor with the `subscriber` mixin.
template <class T> template <class T>
static typename std::enable_if< static
std::is_base_of<mixin::subscriber_base, T>::value, typename std::enable_if<std::is_base_of<mixin::subscriber_base, T>::value,
std::string std::string>::type
>::type joined_groups_of(const T& x) {
joined_groups_of(const T& x) {
return deep_to_string(x.joined_groups()); return deep_to_string(x.joined_groups());
} }
/// Returns a string representation of an empty list if `x` is not an actor /// Returns a string representation of an empty list if `x` is not an actor
/// with the `subscriber` mixin. /// with the `subscriber` mixin.
template <class T> template <class T>
static typename std::enable_if< static
!std::is_base_of<mixin::subscriber_base, T>::value, typename std::enable_if<!std::is_base_of<mixin::subscriber_base, T>::value,
const char* const char*>::type
>::type joined_groups_of(const T& x) {
joined_groups_of(const T& x) {
CAF_IGNORE_UNUSED(x); CAF_IGNORE_UNUSED(x);
return "[]"; return "[]";
} }
...@@ -402,7 +400,7 @@ bool operator==(const logger::field& x, const logger::field& y); ...@@ -402,7 +400,7 @@ bool operator==(const logger::field& x, const logger::field& y);
#ifndef CAF_LOG_COMPONENT #ifndef CAF_LOG_COMPONENT
/// Name of the current component when logging. /// Name of the current component when logging.
#define CAF_LOG_COMPONENT "caf" # define CAF_LOG_COMPONENT "caf"
#endif // CAF_LOG_COMPONENT #endif // CAF_LOG_COMPONENT
// -- utility macros ----------------------------------------------------------- // -- utility macros -----------------------------------------------------------
...@@ -410,23 +408,22 @@ bool operator==(const logger::field& x, const logger::field& y); ...@@ -410,23 +408,22 @@ bool operator==(const logger::field& x, const logger::field& y);
#ifdef CAF_MSVC #ifdef CAF_MSVC
/// Expands to a string representation of the current funciton name that /// Expands to a string representation of the current funciton name that
/// includes the full function name and its signature. /// includes the full function name and its signature.
#define CAF_PRETTY_FUN __FUNCSIG__ # define CAF_PRETTY_FUN __FUNCSIG__
#else // CAF_MSVC #else // CAF_MSVC
/// Expands to a string representation of the current funciton name that /// Expands to a string representation of the current funciton name that
/// includes the full function name and its signature. /// includes the full function name and its signature.
#define CAF_PRETTY_FUN __PRETTY_FUNCTION__ # define CAF_PRETTY_FUN __PRETTY_FUNCTION__
#endif // CAF_MSVC #endif // CAF_MSVC
/// Concatenates `a` and `b` to a single preprocessor token. /// Concatenates `a` and `b` to a single preprocessor token.
#define CAF_CAT(a, b) a##b #define CAF_CAT(a, b) a##b
#define CAF_LOG_MAKE_EVENT(aid, component, loglvl, message) \ #define CAF_LOG_MAKE_EVENT(aid, component, loglvl, message) \
::caf::logger::event ( \ ::caf::logger::event(loglvl, __LINE__, caf::atom(component), CAF_PRETTY_FUN, \
loglvl, __LINE__, caf::atom(component), CAF_PRETTY_FUN, __func__, \ __func__, caf::logger::skip_path(__FILE__), \
caf::logger::skip_path(__FILE__), \ (::caf::logger::line_builder{} << message).get(), \
(::caf::logger::line_builder{} << message).get(), \ ::std::this_thread::get_id(), aid, \
::std::this_thread::get_id(), aid, ::caf::make_timestamp() \ ::caf::make_timestamp())
)
/// Expands to `argument = <argument>` in log output. /// Expands to `argument = <argument>` in log output.
#define CAF_ARG(argument) caf::detail::make_arg_wrapper(#argument, argument) #define CAF_ARG(argument) caf::detail::make_arg_wrapper(#argument, argument)
...@@ -474,74 +471,74 @@ bool operator==(const logger::field& x, const logger::field& y); ...@@ -474,74 +471,74 @@ bool operator==(const logger::field& x, const logger::field& y);
#if CAF_LOG_LEVEL < CAF_LOG_LEVEL_TRACE #if CAF_LOG_LEVEL < CAF_LOG_LEVEL_TRACE
#define CAF_LOG_TRACE(unused) CAF_VOID_STMT # define CAF_LOG_TRACE(unused) CAF_VOID_STMT
#else // CAF_LOG_LEVEL < CAF_LOG_LEVEL_TRACE #else // CAF_LOG_LEVEL < CAF_LOG_LEVEL_TRACE
#define CAF_LOG_TRACE(entry_message) \ # define CAF_LOG_TRACE(entry_message) \
CAF_LOG_IMPL(CAF_LOG_COMPONENT, CAF_LOG_LEVEL_TRACE, \ CAF_LOG_IMPL(CAF_LOG_COMPONENT, CAF_LOG_LEVEL_TRACE, \
"ENTRY" << entry_message); \ "ENTRY" << entry_message); \
auto CAF_UNIFYN(caf_log_trace_guard_) = ::caf::detail::make_scope_guard( \ auto CAF_UNIFYN(caf_log_trace_guard_) = ::caf::detail::make_scope_guard( \
[=] { CAF_LOG_IMPL(CAF_LOG_COMPONENT, CAF_LOG_LEVEL_TRACE, "EXIT"); }) [=] { CAF_LOG_IMPL(CAF_LOG_COMPONENT, CAF_LOG_LEVEL_TRACE, "EXIT"); })
#endif // CAF_LOG_LEVEL < CAF_LOG_LEVEL_TRACE #endif // CAF_LOG_LEVEL < CAF_LOG_LEVEL_TRACE
#if CAF_LOG_LEVEL >= CAF_LOG_LEVEL_DEBUG #if CAF_LOG_LEVEL >= CAF_LOG_LEVEL_DEBUG
#define CAF_LOG_DEBUG(output) \ # define CAF_LOG_DEBUG(output) \
CAF_LOG_IMPL(CAF_LOG_COMPONENT, CAF_LOG_LEVEL_DEBUG, output) CAF_LOG_IMPL(CAF_LOG_COMPONENT, CAF_LOG_LEVEL_DEBUG, output)
#endif #endif
#if CAF_LOG_LEVEL >= CAF_LOG_LEVEL_INFO #if CAF_LOG_LEVEL >= CAF_LOG_LEVEL_INFO
#define CAF_LOG_INFO(output) \ # define CAF_LOG_INFO(output) \
CAF_LOG_IMPL(CAF_LOG_COMPONENT, CAF_LOG_LEVEL_INFO, output) CAF_LOG_IMPL(CAF_LOG_COMPONENT, CAF_LOG_LEVEL_INFO, output)
#endif #endif
#if CAF_LOG_LEVEL >= CAF_LOG_LEVEL_WARNING #if CAF_LOG_LEVEL >= CAF_LOG_LEVEL_WARNING
#define CAF_LOG_WARNING(output) \ # define CAF_LOG_WARNING(output) \
CAF_LOG_IMPL(CAF_LOG_COMPONENT, CAF_LOG_LEVEL_WARNING, output) CAF_LOG_IMPL(CAF_LOG_COMPONENT, CAF_LOG_LEVEL_WARNING, output)
#endif #endif
#define CAF_LOG_ERROR(output) \ #define CAF_LOG_ERROR(output) \
CAF_LOG_IMPL(CAF_LOG_COMPONENT, CAF_LOG_LEVEL_ERROR, output) CAF_LOG_IMPL(CAF_LOG_COMPONENT, CAF_LOG_LEVEL_ERROR, output)
#ifndef CAF_LOG_INFO #ifndef CAF_LOG_INFO
#define CAF_LOG_INFO(output) CAF_VOID_STMT # define CAF_LOG_INFO(output) CAF_VOID_STMT
#define CAF_LOG_INFO_IF(cond, output) CAF_VOID_STMT # define CAF_LOG_INFO_IF(cond, output) CAF_VOID_STMT
#else // CAF_LOG_INFO #else // CAF_LOG_INFO
#define CAF_LOG_INFO_IF(cond, output) \ # define CAF_LOG_INFO_IF(cond, output) \
if (cond) \ if (cond) \
CAF_LOG_IMPL(CAF_LOG_COMPONENT, CAF_LOG_LEVEL_INFO, output); \ CAF_LOG_IMPL(CAF_LOG_COMPONENT, CAF_LOG_LEVEL_INFO, output); \
CAF_VOID_STMT CAF_VOID_STMT
#endif // CAF_LOG_INFO #endif // CAF_LOG_INFO
#ifndef CAF_LOG_DEBUG #ifndef CAF_LOG_DEBUG
#define CAF_LOG_DEBUG(output) CAF_VOID_STMT # define CAF_LOG_DEBUG(output) CAF_VOID_STMT
#define CAF_LOG_DEBUG_IF(cond, output) CAF_VOID_STMT # define CAF_LOG_DEBUG_IF(cond, output) CAF_VOID_STMT
#else // CAF_LOG_DEBUG #else // CAF_LOG_DEBUG
#define CAF_LOG_DEBUG_IF(cond, output) \ # define CAF_LOG_DEBUG_IF(cond, output) \
if (cond) \ if (cond) \
CAF_LOG_IMPL(CAF_LOG_COMPONENT, CAF_LOG_LEVEL_DEBUG, output); \ CAF_LOG_IMPL(CAF_LOG_COMPONENT, CAF_LOG_LEVEL_DEBUG, output); \
CAF_VOID_STMT CAF_VOID_STMT
#endif // CAF_LOG_DEBUG #endif // CAF_LOG_DEBUG
#ifndef CAF_LOG_WARNING #ifndef CAF_LOG_WARNING
#define CAF_LOG_WARNING(output) CAF_VOID_STMT # define CAF_LOG_WARNING(output) CAF_VOID_STMT
#define CAF_LOG_WARNING_IF(cond, output) CAF_VOID_STMT # define CAF_LOG_WARNING_IF(cond, output) CAF_VOID_STMT
#else // CAF_LOG_WARNING #else // CAF_LOG_WARNING
#define CAF_LOG_WARNING_IF(cond, output) \ # define CAF_LOG_WARNING_IF(cond, output) \
if (cond) \ if (cond) \
CAF_LOG_IMPL(CAF_LOG_COMPONENT, CAF_LOG_LEVEL_WARNING, output); \ CAF_LOG_IMPL(CAF_LOG_COMPONENT, CAF_LOG_LEVEL_WARNING, output); \
CAF_VOID_STMT CAF_VOID_STMT
#endif // CAF_LOG_WARNING #endif // CAF_LOG_WARNING
#ifndef CAF_LOG_ERROR #ifndef CAF_LOG_ERROR
#define CAF_LOG_ERROR(output) CAF_VOID_STMT # define CAF_LOG_ERROR(output) CAF_VOID_STMT
#define CAF_LOG_ERROR_IF(cond, output) CAF_VOID_STMT # define CAF_LOG_ERROR_IF(cond, output) CAF_VOID_STMT
#else // CAF_LOG_ERROR #else // CAF_LOG_ERROR
#define CAF_LOG_ERROR_IF(cond, output) \ # define CAF_LOG_ERROR_IF(cond, output) \
if (cond) \ if (cond) \
CAF_LOG_IMPL(CAF_LOG_COMPONENT, CAF_LOG_LEVEL_ERROR, output); \ CAF_LOG_IMPL(CAF_LOG_COMPONENT, CAF_LOG_LEVEL_ERROR, output); \
CAF_VOID_STMT CAF_VOID_STMT
#endif // CAF_LOG_ERROR #endif // CAF_LOG_ERROR
// -- macros for logging CE-0001 events ---------------------------------------- // -- macros for logging CE-0001 events ----------------------------------------
...@@ -552,83 +549,87 @@ bool operator==(const logger::field& x, const logger::field& y); ...@@ -552,83 +549,87 @@ bool operator==(const logger::field& x, const logger::field& y);
#if CAF_LOG_LEVEL >= CAF_LOG_LEVEL_DEBUG #if CAF_LOG_LEVEL >= CAF_LOG_LEVEL_DEBUG
#define CAF_LOG_SPAWN_EVENT(ref, ctor_data) \ # define CAF_LOG_SPAWN_EVENT(ref, ctor_data) \
CAF_LOG_IMPL(CAF_LOG_FLOW_COMPONENT, CAF_LOG_LEVEL_DEBUG, \ CAF_LOG_IMPL(CAF_LOG_FLOW_COMPONENT, CAF_LOG_LEVEL_DEBUG, \
"SPAWN ; ID =" \ "SPAWN ; ID =" \
<< ref.id() << "; NAME =" << ref.name() \ << ref.id() << "; NAME =" << ref.name() << "; TYPE =" \
<< "; TYPE =" << ::caf::detail::pretty_type_name(typeid(ref)) \ << ::caf::detail::pretty_type_name(typeid(ref)) \
<< "; ARGS =" << ctor_data.c_str() \ << "; ARGS =" << ctor_data.c_str() \
<< "; NODE =" << ref.node() \ << "; NODE =" << ref.node() \
<< "; GROUPS =" << ::caf::logger::joined_groups_of(ref)) << "; GROUPS =" << ::caf::logger::joined_groups_of(ref))
#define CAF_LOG_SEND_EVENT(ptr) \ # define CAF_LOG_SEND_EVENT(ptr) \
CAF_LOG_IMPL( \ CAF_LOG_IMPL(CAF_LOG_FLOW_COMPONENT, CAF_LOG_LEVEL_DEBUG, \
CAF_LOG_FLOW_COMPONENT, CAF_LOG_LEVEL_DEBUG, \ "SEND ; TO =" \
"SEND ; TO =" \ << ::caf::deep_to_string( \
<< ::caf::deep_to_string(::caf::strong_actor_ptr{this->ctrl()}).c_str() \ ::caf::strong_actor_ptr{this->ctrl()}) \
<< "; FROM =" << ::caf::deep_to_string(ptr->sender).c_str() \ .c_str() \
<< "; STAGES =" << ::caf::deep_to_string(ptr->stages).c_str() \ << "; FROM =" << ::caf::deep_to_string(ptr->sender).c_str() \
<< "; CONTENT =" << ::caf::deep_to_string(ptr->content()).c_str()) << "; STAGES =" \
<< ::caf::deep_to_string(ptr->stages).c_str() \
#define CAF_LOG_RECEIVE_EVENT(ptr) \ << "; CONTENT =" \
CAF_LOG_IMPL(CAF_LOG_FLOW_COMPONENT, CAF_LOG_LEVEL_DEBUG, \ << ::caf::deep_to_string(ptr->content()).c_str())
"RECEIVE ; FROM =" \
<< ::caf::deep_to_string(ptr->sender).c_str() \ # define CAF_LOG_RECEIVE_EVENT(ptr) \
<< "; STAGES =" << ::caf::deep_to_string(ptr->stages).c_str() \ CAF_LOG_IMPL(CAF_LOG_FLOW_COMPONENT, CAF_LOG_LEVEL_DEBUG, \
<< "; CONTENT =" \ "RECEIVE ; FROM =" \
<< ::caf::deep_to_string(ptr->content()).c_str()) << ::caf::deep_to_string(ptr->sender).c_str() \
<< "; STAGES =" \
#define CAF_LOG_REJECT_EVENT() \ << ::caf::deep_to_string(ptr->stages).c_str() \
CAF_LOG_IMPL(CAF_LOG_FLOW_COMPONENT, CAF_LOG_LEVEL_DEBUG, "REJECT") << "; CONTENT =" \
<< ::caf::deep_to_string(ptr->content()).c_str())
#define CAF_LOG_ACCEPT_EVENT(unblocked) \
CAF_LOG_IMPL(CAF_LOG_FLOW_COMPONENT, CAF_LOG_LEVEL_DEBUG, \ # define CAF_LOG_REJECT_EVENT() \
"ACCEPT ; UNBLOCKED =" << unblocked) CAF_LOG_IMPL(CAF_LOG_FLOW_COMPONENT, CAF_LOG_LEVEL_DEBUG, "REJECT")
#define CAF_LOG_DROP_EVENT() \ # define CAF_LOG_ACCEPT_EVENT(unblocked) \
CAF_LOG_IMPL(CAF_LOG_FLOW_COMPONENT, CAF_LOG_LEVEL_DEBUG, "DROP") CAF_LOG_IMPL(CAF_LOG_FLOW_COMPONENT, CAF_LOG_LEVEL_DEBUG, \
"ACCEPT ; UNBLOCKED =" << unblocked)
#define CAF_LOG_SKIP_EVENT() \
CAF_LOG_IMPL(CAF_LOG_FLOW_COMPONENT, CAF_LOG_LEVEL_DEBUG, "SKIP") # define CAF_LOG_DROP_EVENT() \
CAF_LOG_IMPL(CAF_LOG_FLOW_COMPONENT, CAF_LOG_LEVEL_DEBUG, "DROP")
#define CAF_LOG_FINALIZE_EVENT() \
CAF_LOG_IMPL(CAF_LOG_FLOW_COMPONENT, CAF_LOG_LEVEL_DEBUG, "FINALIZE") # define CAF_LOG_SKIP_EVENT() \
CAF_LOG_IMPL(CAF_LOG_FLOW_COMPONENT, CAF_LOG_LEVEL_DEBUG, "SKIP")
#define CAF_LOG_SKIP_OR_FINALIZE_EVENT(invoke_result) \
do { \ # define CAF_LOG_FINALIZE_EVENT() \
if (invoke_result == caf::invoke_message_result::skipped) \ CAF_LOG_IMPL(CAF_LOG_FLOW_COMPONENT, CAF_LOG_LEVEL_DEBUG, "FINALIZE")
CAF_LOG_SKIP_EVENT(); \
else \ # define CAF_LOG_SKIP_OR_FINALIZE_EVENT(invoke_result) \
CAF_LOG_FINALIZE_EVENT(); \ do { \
} while (false) if (invoke_result == caf::invoke_message_result::skipped) \
CAF_LOG_SKIP_EVENT(); \
#define CAF_LOG_TERMINATE_EVENT(thisptr, rsn) \ else \
CAF_LOG_IMPL(CAF_LOG_FLOW_COMPONENT, CAF_LOG_LEVEL_DEBUG, \ CAF_LOG_FINALIZE_EVENT(); \
"TERMINATE ; ID =" << thisptr->id() \ } while (false)
<< "; REASON =" << deep_to_string(rsn).c_str() \
<< "; NODE =" << thisptr->node()) # define CAF_LOG_TERMINATE_EVENT(thisptr, rsn) \
CAF_LOG_IMPL(CAF_LOG_FLOW_COMPONENT, CAF_LOG_LEVEL_DEBUG, \
"TERMINATE ; ID =" << thisptr->id() << "; REASON =" \
<< deep_to_string(rsn).c_str() \
<< "; NODE =" << thisptr->node())
#else // CAF_LOG_LEVEL >= CAF_LOG_LEVEL_DEBUG #else // CAF_LOG_LEVEL >= CAF_LOG_LEVEL_DEBUG
#define CAF_LOG_SPAWN_EVENT(ref, ctor_data) CAF_VOID_STMT # define CAF_LOG_SPAWN_EVENT(ref, ctor_data) CAF_VOID_STMT
#define CAF_LOG_SEND_EVENT(ptr) CAF_VOID_STMT # define CAF_LOG_SEND_EVENT(ptr) CAF_VOID_STMT
#define CAF_LOG_RECEIVE_EVENT(ptr) CAF_VOID_STMT # define CAF_LOG_RECEIVE_EVENT(ptr) CAF_VOID_STMT
#define CAF_LOG_REJECT_EVENT() CAF_VOID_STMT # define CAF_LOG_REJECT_EVENT() CAF_VOID_STMT
#define CAF_LOG_ACCEPT_EVENT(unblocked) CAF_VOID_STMT # define CAF_LOG_ACCEPT_EVENT(unblocked) CAF_VOID_STMT
#define CAF_LOG_DROP_EVENT() CAF_VOID_STMT # define CAF_LOG_DROP_EVENT() CAF_VOID_STMT
#define CAF_LOG_SKIP_EVENT() CAF_VOID_STMT # define CAF_LOG_SKIP_EVENT() CAF_VOID_STMT
#define CAF_LOG_SKIP_OR_FINALIZE_EVENT(unused) CAF_VOID_STMT # define CAF_LOG_SKIP_OR_FINALIZE_EVENT(unused) CAF_VOID_STMT
#define CAF_LOG_FINALIZE_EVENT() CAF_VOID_STMT # define CAF_LOG_FINALIZE_EVENT() CAF_VOID_STMT
#define CAF_LOG_TERMINATE_EVENT(thisptr, rsn) CAF_VOID_STMT # define CAF_LOG_TERMINATE_EVENT(thisptr, rsn) CAF_VOID_STMT
#endif // CAF_LOG_LEVEL >= CAF_LOG_LEVEL_DEBUG #endif // CAF_LOG_LEVEL >= CAF_LOG_LEVEL_DEBUG
...@@ -639,12 +640,12 @@ bool operator==(const logger::field& x, const logger::field& y); ...@@ -639,12 +640,12 @@ bool operator==(const logger::field& x, const logger::field& y);
#define CAF_LOG_STREAM_COMPONENT "caf_stream" #define CAF_LOG_STREAM_COMPONENT "caf_stream"
#if CAF_LOG_LEVEL >= CAF_LOG_LEVEL_DEBUG #if CAF_LOG_LEVEL >= CAF_LOG_LEVEL_DEBUG
#define CAF_STREAM_LOG_DEBUG(output) \ # define CAF_STREAM_LOG_DEBUG(output) \
CAF_LOG_IMPL(CAF_LOG_STREAM_COMPONENT, CAF_LOG_LEVEL_DEBUG, output) CAF_LOG_IMPL(CAF_LOG_STREAM_COMPONENT, CAF_LOG_LEVEL_DEBUG, output)
#define CAF_STREAM_LOG_DEBUG_IF(condition, output) \ # define CAF_STREAM_LOG_DEBUG_IF(condition, output) \
if (condition) \ if (condition) \
CAF_LOG_IMPL(CAF_LOG_STREAM_COMPONENT, CAF_LOG_LEVEL_DEBUG, output) CAF_LOG_IMPL(CAF_LOG_STREAM_COMPONENT, CAF_LOG_LEVEL_DEBUG, output)
#else #else
#define CAF_STREAM_LOG_DEBUG(unused) CAF_VOID_STMT # define CAF_STREAM_LOG_DEBUG(unused) CAF_VOID_STMT
#define CAF_STREAM_LOG_DEBUG_IF(unused1, unused2) CAF_VOID_STMT # define CAF_STREAM_LOG_DEBUG_IF(unused1, unused2) CAF_VOID_STMT
#endif #endif
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