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
5ea96794
Commit
5ea96794
authored
Jan 10, 2019
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'topic/component-blacklist'
parents
b3b8fc9b
1f8a509b
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
42 additions
and
28 deletions
+42
-28
examples/caf-application.ini
examples/caf-application.ini
+2
-2
libcaf_core/caf/logger.hpp
libcaf_core/caf/logger.hpp
+9
-8
libcaf_core/caf/make_actor.hpp
libcaf_core/caf/make_actor.hpp
+1
-1
libcaf_core/caf/optional.hpp
libcaf_core/caf/optional.hpp
+14
-1
libcaf_core/src/actor_system_config.cpp
libcaf_core/src/actor_system_config.cpp
+3
-1
libcaf_core/src/logger.cpp
libcaf_core/src/logger.cpp
+11
-13
libcaf_core/test/logger.cpp
libcaf_core/test/logger.cpp
+2
-2
No files found.
examples/caf-application.ini
View file @
5ea96794
...
@@ -73,5 +73,5 @@ console-format="%m"
...
@@ -73,5 +73,5 @@ console-format="%m"
; configures the minimum severity of messages that are written to the console
; configures the minimum severity of messages that are written to the console
; (quiet|error|warning|info|debug|trace)
; (quiet|error|warning|info|debug|trace)
console-verbosity
=
'trace'
console-verbosity
=
'trace'
; excludes listed components from logging
; excludes listed components from logging
(list of atoms)
component-
filter
=
""
component-
blacklist
=
[]
libcaf_core/caf/logger.hpp
View file @
5ea96794
...
@@ -28,11 +28,12 @@
...
@@ -28,11 +28,12 @@
#include <unordered_map>
#include <unordered_map>
#include "caf/abstract_actor.hpp"
#include "caf/abstract_actor.hpp"
#include "caf/atom.hpp"
#include "caf/config.hpp"
#include "caf/config.hpp"
#include "caf/deep_to_string.hpp"
#include "caf/deep_to_string.hpp"
#include "caf/detail/arg_wrapper.hpp"
#include "caf/detail/arg_wrapper.hpp"
#include "caf/detail/pretty_type_name.hpp"
#include "caf/detail/log_level.hpp"
#include "caf/detail/log_level.hpp"
#include "caf/detail/pretty_type_name.hpp"
#include "caf/detail/ringbuffer.hpp"
#include "caf/detail/ringbuffer.hpp"
#include "caf/detail/scope_guard.hpp"
#include "caf/detail/scope_guard.hpp"
#include "caf/detail/shared_spinlock.hpp"
#include "caf/detail/shared_spinlock.hpp"
...
@@ -113,7 +114,7 @@ public:
...
@@ -113,7 +114,7 @@ public:
event
&
operator
=
(
const
event
&
)
=
default
;
event
&
operator
=
(
const
event
&
)
=
default
;
event
(
unsigned
lvl
,
unsigned
line
,
string_view
cat
,
string_view
full_fun
,
event
(
unsigned
lvl
,
unsigned
line
,
atom_value
cat
,
string_view
full_fun
,
string_view
fun
,
string_view
fn
,
std
::
string
msg
,
std
::
thread
::
id
t
,
string_view
fun
,
string_view
fn
,
std
::
string
msg
,
std
::
thread
::
id
t
,
actor_id
a
,
timestamp
ts
);
actor_id
a
,
timestamp
ts
);
...
@@ -126,7 +127,7 @@ public:
...
@@ -126,7 +127,7 @@ public:
unsigned
line_number
;
unsigned
line_number
;
/// Name of the category (component) logging the event.
/// Name of the category (component) logging the event.
string_view
category_name
;
atom_value
category_name
;
/// Name of the current function as reported by `__PRETTY_FUNCTION__`.
/// Name of the current function as reported by `__PRETTY_FUNCTION__`.
string_view
pretty_fun
;
string_view
pretty_fun
;
...
@@ -228,7 +229,7 @@ public:
...
@@ -228,7 +229,7 @@ public:
/// Returns whether the logger is configured to accept input for given
/// Returns whether the logger is configured to accept input for given
/// component and log level.
/// component and log level.
bool
accepts
(
unsigned
level
,
string_view
component_name
);
bool
accepts
(
unsigned
level
,
atom_value
component_name
);
/// Returns the output format used for the log file.
/// Returns the output format used for the log file.
const
line_format
&
file_format
()
const
{
const
line_format
&
file_format
()
const
{
...
@@ -345,7 +346,7 @@ private:
...
@@ -345,7 +346,7 @@ private:
config
cfg_
;
config
cfg_
;
// Filters events by component name.
// Filters events by component name.
std
::
string
component_filter
;
std
::
vector
<
atom_value
>
component_blacklist
;
// References the parent system.
// References the parent system.
actor_system
&
system_
;
actor_system
&
system_
;
...
@@ -416,7 +417,7 @@ bool operator==(const logger::field& x, const logger::field& y);
...
@@ -416,7 +417,7 @@ bool operator==(const logger::field& x, const logger::field& y);
#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__, c
omponent, CAF_PRETTY_FUN, __func__,
\
loglvl, __LINE__, c
af::atom(component), CAF_PRETTY_FUN, __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, ::caf::make_timestamp() \
::std::this_thread::get_id(), aid, ::caf::make_timestamp() \
...
@@ -457,7 +458,7 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; }
...
@@ -457,7 +458,7 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; }
do { \
do { \
auto CAF_UNIFYN(caf_logger) = caf::logger::current_logger(); \
auto CAF_UNIFYN(caf_logger) = caf::logger::current_logger(); \
if (CAF_UNIFYN(caf_logger) != nullptr \
if (CAF_UNIFYN(caf_logger) != nullptr \
&& CAF_UNIFYN(caf_logger)->accepts(loglvl, c
omponent))
\
&& CAF_UNIFYN(caf_logger)->accepts(loglvl, c
af::atom(component)))
\
CAF_UNIFYN(caf_logger) \
CAF_UNIFYN(caf_logger) \
->log(CAF_LOG_MAKE_EVENT(CAF_UNIFYN(caf_logger)->thread_local_aid(), \
->log(CAF_LOG_MAKE_EVENT(CAF_UNIFYN(caf_logger)->thread_local_aid(), \
component, loglvl, message)); \
component, loglvl, message)); \
...
@@ -563,7 +564,7 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; }
...
@@ -563,7 +564,7 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; }
/// The log component responsible for logging control flow events that are
/// The log component responsible for logging control flow events that are
/// crucial for understanding happens-before relations. See RFC SE-0001.
/// crucial for understanding happens-before relations. See RFC SE-0001.
#define CAF_LOG_FLOW_COMPONENT "caf
.
flow"
#define CAF_LOG_FLOW_COMPONENT "caf
_
flow"
#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, \
...
...
libcaf_core/caf/make_actor.hpp
View file @
5ea96794
...
@@ -35,7 +35,7 @@ R make_actor(actor_id aid, node_id nid, actor_system* sys, Ts&&... xs) {
...
@@ -35,7 +35,7 @@ R make_actor(actor_id aid, node_id nid, actor_system* sys, Ts&&... xs) {
#if CAF_LOG_LEVEL >= CAF_LOG_LEVEL_DEBUG
#if CAF_LOG_LEVEL >= CAF_LOG_LEVEL_DEBUG
actor_storage
<
T
>*
ptr
=
nullptr
;
actor_storage
<
T
>*
ptr
=
nullptr
;
if
(
logger
::
current_logger
()
->
accepts
(
CAF_LOG_LEVEL_DEBUG
,
if
(
logger
::
current_logger
()
->
accepts
(
CAF_LOG_LEVEL_DEBUG
,
CAF_LOG_FLOW_COMPONENT
))
{
caf
::
atom
(
CAF_LOG_FLOW_COMPONENT
)
))
{
std
::
string
args
;
std
::
string
args
;
args
=
deep_to_string
(
std
::
forward_as_tuple
(
xs
...));
args
=
deep_to_string
(
std
::
forward_as_tuple
(
xs
...));
ptr
=
new
actor_storage
<
T
>
(
aid
,
std
::
move
(
nid
),
sys
,
ptr
=
new
actor_storage
<
T
>
(
aid
,
std
::
move
(
nid
),
sys
,
...
...
libcaf_core/caf/optional.hpp
View file @
5ea96794
...
@@ -305,6 +305,20 @@ std::string to_string(const optional<T>& x) {
...
@@ -305,6 +305,20 @@ std::string to_string(const optional<T>& x) {
return
x
?
"*"
+
deep_to_string
(
*
x
)
:
"none"
;
return
x
?
"*"
+
deep_to_string
(
*
x
)
:
"none"
;
}
}
/// Returns an rvalue to the value managed by `x`.
/// @relates optional
template
<
class
T
>
T
&&
move_if_optional
(
optional
<
T
>&
x
)
{
return
std
::
move
(
*
x
);
}
/// Returns `*x`.
/// @relates optional
template
<
class
T
>
T
&
move_if_optional
(
T
*
x
)
{
return
*
x
;
}
// -- [X.Y.8] comparison with optional ----------------------------------------
// -- [X.Y.8] comparison with optional ----------------------------------------
/// @relates optional
/// @relates optional
...
@@ -493,4 +507,3 @@ bool operator>=(const T& lhs, const optional<T>& rhs) {
...
@@ -493,4 +507,3 @@ bool operator>=(const T& lhs, const optional<T>& rhs) {
}
}
}
// namespace caf
}
// namespace caf
libcaf_core/src/actor_system_config.cpp
View file @
5ea96794
...
@@ -157,6 +157,8 @@ actor_system_config::actor_system_config()
...
@@ -157,6 +157,8 @@ actor_system_config::actor_system_config()
"sets the console output verbosity "
"sets the console output verbosity "
"(quiet|error|warning|info|debug|trace)"
)
"(quiet|error|warning|info|debug|trace)"
)
.
add
(
logger_component_filter
,
"component-filter"
,
.
add
(
logger_component_filter
,
"component-filter"
,
"DEPRECATED/IGNORED, use component-blacklist instead"
)
.
add
<
std
::
vector
<
atom_value
>>
(
"component-blacklist"
,
"exclude all listed components from logging"
)
"exclude all listed components from logging"
)
.
add
(
logger_verbosity
,
"verbosity"
,
.
add
(
logger_verbosity
,
"verbosity"
,
"set file and console verbosity (deprecated)"
)
"set file and console verbosity (deprecated)"
)
...
...
libcaf_core/src/logger.cpp
View file @
5ea96794
...
@@ -254,7 +254,7 @@ logger::config::config()
...
@@ -254,7 +254,7 @@ logger::config::config()
// nop
// nop
}
}
logger
::
event
::
event
(
unsigned
lvl
,
unsigned
line
,
string_view
cat
,
logger
::
event
::
event
(
unsigned
lvl
,
unsigned
line
,
atom_value
cat
,
string_view
full_fun
,
string_view
fun
,
string_view
fn
,
string_view
full_fun
,
string_view
fun
,
string_view
fn
,
std
::
string
msg
,
std
::
thread
::
id
t
,
actor_id
a
,
std
::
string
msg
,
std
::
thread
::
id
t
,
actor_id
a
,
timestamp
ts
)
timestamp
ts
)
...
@@ -351,15 +351,11 @@ logger* logger::current_logger() {
...
@@ -351,15 +351,11 @@ logger* logger::current_logger() {
return
get_current_logger
();
return
get_current_logger
();
}
}
bool
logger
::
accepts
(
unsigned
level
,
string_view
cname
)
{
bool
logger
::
accepts
(
unsigned
level
,
atom_value
cname
)
{
if
(
level
>
cfg_
.
verbosity
)
if
(
level
>
cfg_
.
verbosity
)
return
false
;
return
false
;
if
(
!
component_filter
.
empty
())
{
return
!
std
::
any_of
(
component_blacklist
.
begin
(),
component_blacklist
.
end
(),
auto
it
=
std
::
search
(
component_filter
.
begin
(),
component_filter
.
end
(),
[
=
](
atom_value
name
)
{
return
name
==
cname
;
});
cname
.
begin
(),
cname
.
end
());
return
it
!=
component_filter
.
end
();
}
return
true
;
}
}
logger
::
logger
(
actor_system
&
sys
)
:
system_
(
sys
)
{
logger
::
logger
(
actor_system
&
sys
)
:
system_
(
sys
)
{
...
@@ -377,8 +373,10 @@ logger::~logger() {
...
@@ -377,8 +373,10 @@ logger::~logger() {
void
logger
::
init
(
actor_system_config
&
cfg
)
{
void
logger
::
init
(
actor_system_config
&
cfg
)
{
CAF_IGNORE_UNUSED
(
cfg
);
CAF_IGNORE_UNUSED
(
cfg
);
namespace
lg
=
defaults
::
logger
;
namespace
lg
=
defaults
::
logger
;
component_filter
=
get_or
(
cfg
,
"logger.component-filter"
,
using
atom_list
=
std
::
vector
<
atom_value
>
;
lg
::
component_filter
);
auto
blacklist
=
get_if
<
atom_list
>
(
&
cfg
,
"logger.component-blacklist"
);
if
(
blacklist
)
component_blacklist
=
move_if_optional
(
blacklist
);
// Parse the configured log level.
// Parse the configured log level.
auto
verbosity
=
get_if
<
atom_value
>
(
&
cfg
,
"logger.verbosity"
);
auto
verbosity
=
get_if
<
atom_value
>
(
&
cfg
,
"logger.verbosity"
);
auto
file_verbosity
=
verbosity
?
*
verbosity
:
lg
::
file_verbosity
;
auto
file_verbosity
=
verbosity
?
*
verbosity
:
lg
::
file_verbosity
;
...
@@ -476,7 +474,7 @@ void logger::render(std::ostream& out, const line_format& lf,
...
@@ -476,7 +474,7 @@ void logger::render(std::ostream& out, const line_format& lf,
const
event
&
x
)
const
{
const
event
&
x
)
const
{
for
(
auto
&
f
:
lf
)
for
(
auto
&
f
:
lf
)
switch
(
f
.
kind
)
{
switch
(
f
.
kind
)
{
case
category_field
:
out
<<
x
.
category_name
;
break
;
case
category_field
:
out
<<
to_string
(
x
.
category_name
)
;
break
;
case
class_name_field
:
render_fun_prefix
(
out
,
x
);
break
;
case
class_name_field
:
render_fun_prefix
(
out
,
x
);
break
;
case
date_field
:
render_date
(
out
,
x
.
tstamp
);
break
;
case
date_field
:
render_date
(
out
,
x
.
tstamp
);
break
;
case
file_field
:
out
<<
x
.
file_name
;
break
;
case
file_field
:
out
<<
x
.
file_name
;
break
;
...
@@ -617,8 +615,8 @@ void logger::log_first_line() {
...
@@ -617,8 +615,8 @@ void logger::log_first_line() {
msg
+=
to_string
(
get_or
(
system_
.
config
(),
config_name
,
default_value
));
msg
+=
to_string
(
get_or
(
system_
.
config
(),
config_name
,
default_value
));
msg
+=
", node = "
;
msg
+=
", node = "
;
msg
+=
to_string
(
system_
.
node
());
msg
+=
to_string
(
system_
.
node
());
msg
+=
", component
_filter
= "
;
msg
+=
", component
-blacklist
= "
;
msg
+=
deep_to_string
(
component_
filter
);
msg
+=
deep_to_string
(
component_
blacklist
);
return
msg
;
return
msg
;
};
};
namespace
lg
=
defaults
::
logger
;
namespace
lg
=
defaults
::
logger
;
...
...
libcaf_core/test/logger.cpp
View file @
5ea96794
...
@@ -180,7 +180,7 @@ CAF_TEST(rendering) {
...
@@ -180,7 +180,7 @@ CAF_TEST(rendering) {
logger
::
event
e
{
logger
::
event
e
{
CAF_LOG_LEVEL_WARNING
,
CAF_LOG_LEVEL_WARNING
,
42
,
42
,
"unit.test"
,
atom
(
"unit_test"
)
,
"void ns::foo::bar()"
,
"void ns::foo::bar()"
,
"bar"
,
"bar"
,
"foo.cpp"
,
"foo.cpp"
,
...
@@ -199,7 +199,7 @@ CAF_TEST(rendering) {
...
@@ -199,7 +199,7 @@ CAF_TEST(rendering) {
using
namespace
std
::
placeholders
;
using
namespace
std
::
placeholders
;
auto
render_event
=
bind
(
&
logger
::
render
,
&
lg
,
_1
,
_2
,
_3
);
auto
render_event
=
bind
(
&
logger
::
render
,
&
lg
,
_1
,
_2
,
_3
);
CAF_CHECK_EQUAL
(
render
(
render_event
,
lf
,
e
),
CAF_CHECK_EQUAL
(
render
(
render_event
,
lf
,
e
),
"unit
.
test WARN actor0 ns.foo bar foo.cpp:42 hello world"
);
"unit
_
test WARN actor0 ns.foo bar foo.cpp:42 hello world"
);
}
}
CAF_TEST
(
render_fun_prefix
)
{
CAF_TEST
(
render_fun_prefix
)
{
...
...
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