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
4c2a3a6f
Commit
4c2a3a6f
authored
Nov 08, 2016
by
Matthias Vallentin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add component filter to console logger
parent
785cb3bd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
7 deletions
+17
-7
libcaf_core/caf/actor_system_config.hpp
libcaf_core/caf/actor_system_config.hpp
+1
-0
libcaf_core/caf/logger.hpp
libcaf_core/caf/logger.hpp
+3
-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
+10
-5
No files found.
libcaf_core/caf/actor_system_config.hpp
View file @
4c2a3a6f
...
...
@@ -257,6 +257,7 @@ public:
std
::
string
logger_filename
;
atom_value
logger_verbosity
;
atom_value
logger_console
;
std
::
string
logger_filter
;
// -- config parameters of the middleman -------------------------------------
...
...
libcaf_core/caf/logger.hpp
View file @
4c2a3a6f
...
...
@@ -65,9 +65,11 @@ public:
event
*
next
;
event
*
prev
;
int
level
;
const
char
*
component
;
std
::
string
prefix
;
std
::
string
msg
;
explicit
event
(
int
l
=
0
,
std
::
string
p
=
""
,
std
::
string
m
=
""
);
explicit
event
(
int
l
=
0
,
char
const
*
c
=
""
,
std
::
string
p
=
""
,
std
::
string
m
=
""
);
};
template
<
class
T
>
...
...
libcaf_core/src/actor_system_config.cpp
View file @
4c2a3a6f
...
...
@@ -137,7 +137,9 @@ actor_system_config::actor_system_config()
.
add
(
logger_verbosity
,
"verbosity"
,
"sets the verbosity (QUIET|ERROR|WARNING|INFO|DEBUG|TRACE)"
)
.
add
(
logger_console
,
"console"
,
"enables logging to the console via std::clog"
);
"enables logging to the console via std::clog"
)
.
add
(
logger_filter
,
"filter"
,
"sets a component filter for console log messages"
);
opt_group
{
options_
,
"middleman"
}
.
add
(
middleman_network_backend
,
"network-backend"
,
"sets the network backend to either 'default' or 'asio' (if available)"
)
...
...
libcaf_core/src/logger.cpp
View file @
4c2a3a6f
...
...
@@ -125,10 +125,11 @@ void prettify_type_name(std::string& class_name, const char* c_class_name) {
}
// namespace <anonymous>
logger
::
event
::
event
(
int
l
,
std
::
string
p
,
std
::
string
m
)
logger
::
event
::
event
(
int
l
,
const
char
*
c
,
std
::
string
p
,
std
::
string
m
)
:
next
(
nullptr
),
prev
(
nullptr
),
level
(
l
),
component
(
c
),
prefix
(
std
::
move
(
p
)),
msg
(
std
::
move
(
m
))
{
// nop
...
...
@@ -248,7 +249,7 @@ void logger::log(int level, const char* component,
<<
" "
<<
class_name
<<
" "
<<
function_name
<<
" "
<<
file_name
<<
":"
<<
line_num
;
queue_
.
synchronized_enqueue
(
queue_mtx_
,
queue_cv_
,
new
event
{
level
,
prefix
.
str
(),
msg
});
new
event
{
level
,
component
,
prefix
.
str
(),
msg
});
}
void
logger
::
set_current_actor_system
(
actor_system
*
x
)
{
...
...
@@ -298,7 +299,7 @@ void logger::run() {
auto
nid
=
to_string
(
system_
.
node
());
f
.
replace
(
i
,
i
+
sizeof
(
node
)
-
1
,
nid
);
}
std
::
fstream
out
(
f
,
std
::
ios
::
out
|
std
::
ios
::
app
);
std
::
fstream
file
(
f
,
std
::
ios
::
out
|
std
::
ios
::
app
);
std
::
unique_ptr
<
event
>
ptr
;
for
(;;)
{
// make sure we have data to read
...
...
@@ -307,10 +308,14 @@ void logger::run() {
ptr
.
reset
(
queue_
.
try_pop
());
CAF_ASSERT
(
ptr
!=
nullptr
);
if
(
ptr
->
msg
.
empty
())
{
out
.
close
();
file
.
close
();
return
;
}
out
<<
ptr
->
prefix
<<
' '
<<
ptr
->
msg
<<
std
::
endl
;
file
<<
ptr
->
prefix
<<
' '
<<
ptr
->
msg
<<
std
::
endl
;
// TODO: once we've phased out GCC 4.8, we can upgarde this to a regex.
if
(
!
system_
.
config
().
logger_filter
.
empty
()
&&
ptr
->
component
!=
system_
.
config
().
logger_filter
)
continue
;
if
(
system_
.
config
().
logger_console
==
atom
(
"UNCOLORED"
))
{
std
::
clog
<<
ptr
->
msg
<<
std
::
endl
;
}
else
if
(
system_
.
config
().
logger_console
==
atom
(
"COLORED"
))
{
...
...
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