Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ORNL Quantum Computing Institute
xacc
Commits
1df2b8ee
Commit
1df2b8ee
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 @
1df2b8ee
...
@@ -270,6 +270,17 @@ void XACCLogger::setLoggingLevel(int level) {
...
@@ -270,6 +270,17 @@ void XACCLogger::setLoggingLevel(int level) {
}
}
}
}
int
XACCLogger
::
getLoggingLevel
()
{
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
)
{
void
XACCLogger
::
info
(
const
std
::
string
&
msg
,
MessagePredicate
predicate
)
{
if
(
useCout
)
{
if
(
useCout
)
{
if
(
predicate
()
&&
globalPredicate
())
{
if
(
predicate
()
&&
globalPredicate
())
{
...
...
xacc/utils/Utils.hpp
View file @
1df2b8ee
...
@@ -201,7 +201,8 @@ public:
...
@@ -201,7 +201,8 @@ public:
// 2: Debug and above
// 2: Debug and above
// Note: this will only take effect when xacc::verbose is set.
// Note: this will only take effect when xacc::verbose is set.
void
setLoggingLevel
(
int
level
);
void
setLoggingLevel
(
int
level
);
int
getLoggingLevel
();
void
subscribeLoggingLevel
(
LoggingLevelNotification
onLevelChangeFn
)
{
void
subscribeLoggingLevel
(
LoggingLevelNotification
onLevelChangeFn
)
{
loggingLevelSubscribers
.
emplace_back
(
onLevelChangeFn
);
loggingLevelSubscribers
.
emplace_back
(
onLevelChangeFn
);
}
}
...
...
xacc/xacc.cpp
View file @
1df2b8ee
...
@@ -119,6 +119,10 @@ void setLoggingLevel(int level) {
...
@@ -119,6 +119,10 @@ void setLoggingLevel(int level) {
XACCLogger
::
instance
()
->
setLoggingLevel
(
level
);
XACCLogger
::
instance
()
->
setLoggingLevel
(
level
);
}
}
int
getLoggingLevel
()
{
return
XACCLogger
::
instance
()
->
getLoggingLevel
();
}
void
subscribeLoggingLevel
(
LoggingLevelNotification
callback
)
{
void
subscribeLoggingLevel
(
LoggingLevelNotification
callback
)
{
XACCLogger
::
instance
()
->
subscribeLoggingLevel
(
callback
);
XACCLogger
::
instance
()
->
subscribeLoggingLevel
(
callback
);
}
}
...
...
xacc/xacc.hpp
View file @
1df2b8ee
...
@@ -97,6 +97,7 @@ void addCommandLineOptions(const std::map<std::string, std::string> &options);
...
@@ -97,6 +97,7 @@ void addCommandLineOptions(const std::map<std::string, std::string> &options);
void
setGlobalLoggerPredicate
(
MessagePredicate
predicate
);
void
setGlobalLoggerPredicate
(
MessagePredicate
predicate
);
void
logToFile
(
bool
enable
);
void
logToFile
(
bool
enable
);
void
setLoggingLevel
(
int
level
);
void
setLoggingLevel
(
int
level
);
int
getLoggingLevel
();
void
subscribeLoggingLevel
(
LoggingLevelNotification
callback
);
void
subscribeLoggingLevel
(
LoggingLevelNotification
callback
);
void
info
(
const
std
::
string
&
msg
,
void
info
(
const
std
::
string
&
msg
,
...
...
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