Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ORNL Quantum Computing Institute
xacc
Commits
ac7b93df
Commit
ac7b93df
authored
Jun 16, 2020
by
Nguyen, Thien Minh
Browse files
Added logging level getter
Signed-off-by:
Thien Nguyen
<
nguyentm@ornl.gov
>
parent
227da88c
Changes
4
Hide whitespace changes
Inline
Side-by-side
xacc/utils/Utils.cpp
View file @
ac7b93df
...
...
@@ -270,6 +270,18 @@ void XACCLogger::setLoggingLevel(int level) {
}
}
int
XACCLogger
::
getLoggingLevel
()
const
{
const
auto
spdLevel
=
getLogger
()
->
level
();
switch
(
spdLevel
)
{
case
spdlog
::
level
::
trace
:
case
spdlog
::
level
::
debug
:
return
2
;
case
spdlog
::
level
::
info
:
return
1
;
default:
return
0
;
}
}
void
XACCLogger
::
info
(
const
std
::
string
&
msg
,
MessagePredicate
predicate
)
{
if
(
useCout
)
{
if
(
predicate
()
&&
globalPredicate
())
{
...
...
xacc/utils/Utils.hpp
View file @
ac7b93df
...
...
@@ -177,6 +177,10 @@ protected:
return
useFile
?
fileLogger
:
stdOutLogger
;
}
std
::
shared_ptr
<
const
spdlog
::
logger
>
getLogger
()
const
{
return
std
::
const_pointer_cast
<
spdlog
::
logger
>
(
getLogger
());
}
// On-demand create a file logger:
// We don't want to create one if not being used.
void
createFileLogger
();
...
...
@@ -201,7 +205,8 @@ public:
// 2: Debug and above
// Note: this will only take effect when xacc::verbose is set.
void
setLoggingLevel
(
int
level
);
int
getLoggingLevel
()
const
;
void
subscribeLoggingLevel
(
LoggingLevelNotification
onLevelChangeFn
)
{
loggingLevelSubscribers
.
emplace_back
(
onLevelChangeFn
);
}
...
...
xacc/xacc.cpp
View file @
ac7b93df
...
...
@@ -119,6 +119,10 @@ void setLoggingLevel(int level) {
XACCLogger
::
instance
()
->
setLoggingLevel
(
level
);
}
int
getLoggingLevel
()
{
return
XACCLogger
::
instance
()
->
getLoggingLevel
();
}
void
subscribeLoggingLevel
(
LoggingLevelNotification
callback
)
{
XACCLogger
::
instance
()
->
subscribeLoggingLevel
(
callback
);
}
...
...
xacc/xacc.hpp
View file @
ac7b93df
...
...
@@ -97,6 +97,7 @@ void addCommandLineOptions(const std::map<std::string, std::string> &options);
void
setGlobalLoggerPredicate
(
MessagePredicate
predicate
);
void
logToFile
(
bool
enable
);
void
setLoggingLevel
(
int
level
);
int
getLoggingLevel
();
void
subscribeLoggingLevel
(
LoggingLevelNotification
callback
);
void
info
(
const
std
::
string
&
msg
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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