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
5ef0b54c
Commit
5ef0b54c
authored
Nov 14, 2016
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use switch-case to parse configured log level
parent
ca902ea7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
18 deletions
+50
-18
libcaf_core/caf/atom.hpp
libcaf_core/caf/atom.hpp
+18
-0
libcaf_core/src/logger.cpp
libcaf_core/src/logger.cpp
+32
-18
No files found.
libcaf_core/caf/atom.hpp
View file @
5ef0b54c
...
@@ -155,6 +155,24 @@ using migrate_atom = atom_constant<atom("migrate")>;
...
@@ -155,6 +155,24 @@ using migrate_atom = atom_constant<atom("migrate")>;
/// Used for triggering periodic operations.
/// Used for triggering periodic operations.
using
tick_atom
=
atom_constant
<
atom
(
"tick"
)
>
;
using
tick_atom
=
atom_constant
<
atom
(
"tick"
)
>
;
/// Used as config parameter for the `logger`.
using
trace_log_lvl_atom
=
atom_constant
<
atom
(
"TRACE"
)
>
;
/// Used as config parameter for the `logger`.
using
debug_log_lvl_atom
=
atom_constant
<
atom
(
"DEBUG"
)
>
;
/// Used as config parameter for the `logger`.
using
info_log_lvl_atom
=
atom_constant
<
atom
(
"INFO"
)
>
;
/// Used as config parameter for the `logger`.
using
warning_log_lvl_atom
=
atom_constant
<
atom
(
"WARNING"
)
>
;
/// Used as config parameter for the `logger`.
using
error_log_lvl_atom
=
atom_constant
<
atom
(
"ERROR"
)
>
;
/// Used as config parameter for the `logger`.
using
quiet_log_lvl_atom
=
atom_constant
<
atom
(
"QUIET"
)
>
;
}
// namespace caf
}
// namespace caf
namespace
std
{
namespace
std
{
...
...
libcaf_core/src/logger.cpp
View file @
5ef0b54c
...
@@ -345,25 +345,39 @@ void logger::run() {
...
@@ -345,25 +345,39 @@ void logger::run() {
void
logger
::
start
()
{
void
logger
::
start
()
{
#if defined(CAF_LOG_LEVEL)
#if defined(CAF_LOG_LEVEL)
auto
&
lvl
=
system_
.
config
().
logger_verbosity
;
auto
lvl_atom
=
system_
.
config
().
logger_verbosity
;
if
(
lvl
==
atom
(
"QUIET"
))
switch
(
static_cast
<
uint64_t
>
(
lvl_atom
))
{
case
quiet_log_lvl_atom
:
:
uint_value
()
:
return
;
return
;
if
(
lvl
==
atom
(
"ERROR"
))
case
error_log_lvl_atom
:
:
uint_value
()
:
level_
=
CAF_LOG_LEVEL_ERROR
;
level_
=
CAF_LOG_LEVEL_ERROR
;
else
if
(
lvl
==
atom
(
"WARNING"
))
break
;
case
warning_log_lvl_atom
:
:
uint_value
()
:
level_
=
CAF_LOG_LEVEL_WARNING
;
level_
=
CAF_LOG_LEVEL_WARNING
;
else
if
(
lvl
==
atom
(
"INFO"
))
break
;
case
info_log_lvl_atom
:
:
uint_value
()
:
level_
=
CAF_LOG_LEVEL_INFO
;
level_
=
CAF_LOG_LEVEL_INFO
;
else
if
(
lvl
==
atom
(
"DEBUG"
))
break
;
case
debug_log_lvl_atom
:
:
uint_value
()
:
level_
=
CAF_LOG_LEVEL_DEBUG
;
level_
=
CAF_LOG_LEVEL_DEBUG
;
else
if
(
lvl
==
atom
(
"TRACE"
))
break
;
case
trace_log_lvl_atom
:
:
uint_value
()
:
level_
=
CAF_LOG_LEVEL_TRACE
;
level_
=
CAF_LOG_LEVEL_TRACE
;
else
break
;
default:
{
constexpr
atom_value
level_names
[]
=
{
error_log_lvl_atom
::
value
,
warning_log_lvl_atom
::
value
,
info_log_lvl_atom
::
value
,
debug_log_lvl_atom
::
value
,
trace_log_lvl_atom
::
value
};
lvl_atom
=
level_names
[
CAF_LOG_LEVEL
];
level_
=
CAF_LOG_LEVEL
;
level_
=
CAF_LOG_LEVEL
;
}
}
thread_
=
std
::
thread
{[
this
]
{
this
->
run
();
}};
thread_
=
std
::
thread
{[
this
]
{
this
->
run
();
}};
std
::
string
msg
=
"ENTRY log level = "
;
std
::
string
msg
=
"ENTRY level = "
;
const
char
*
levels
[]
=
{
"ERROR"
,
"WARNING"
,
"INFO"
,
"DEBUG"
,
"TRACE"
};
msg
+=
to_string
(
lvl_atom
);
msg
+=
levels
[
level_
];
msg
+=
", node = "
;
msg
+=
to_string
(
system_
.
node
());
log
(
CAF_LOG_LEVEL_INFO
,
"caf"
,
"caf::logger"
,
"run"
,
__FILE__
,
__LINE__
,
msg
);
log
(
CAF_LOG_LEVEL_INFO
,
"caf"
,
"caf::logger"
,
"run"
,
__FILE__
,
__LINE__
,
msg
);
#endif
#endif
}
}
...
...
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