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
a677316c
Commit
a677316c
authored
Feb 19, 2018
by
Mccaskey, Alex
Browse files
adding warning function to api
Signed-off-by:
Alex McCaskey
<
mccaskeyaj@ornl.gov
>
parent
8c776c19
Changes
4
Hide whitespace changes
Inline
Side-by-side
xacc/XACC.cpp
View file @
a677316c
...
...
@@ -113,6 +113,10 @@ void info(const std::string& msg, MessagePredicate predicate) {
XACCLogger
::
instance
()
->
info
(
msg
,
predicate
);
}
void
warning
(
const
std
::
string
&
msg
,
MessagePredicate
predicate
)
{
XACCLogger
::
instance
()
->
warning
(
msg
,
predicate
);
}
void
debug
(
const
std
::
string
&
msg
,
MessagePredicate
predicate
)
{
XACCLogger
::
instance
()
->
debug
(
msg
,
predicate
);
}
...
...
xacc/XACC.hpp
View file @
a677316c
...
...
@@ -116,6 +116,14 @@ void setGlobalLoggerPredicate(MessagePredicate predicate);
*/
void
info
(
const
std
::
string
&
msg
,
MessagePredicate
predicate
=
std
::
function
<
bool
(
void
)
>
([]()
{
return
true
;}));
/**
* Print a warning log to the XACC Logger.
*
* @param msg The log to print
* @param predicate Function with no arguments that returns bool
*/
void
warning
(
const
std
::
string
&
msg
,
MessagePredicate
predicate
=
std
::
function
<
bool
(
void
)
>
([]()
{
return
true
;}));
/**
* Print an debug log to the XACC Logger.
*
...
...
xacc/utils/Utils.cpp
View file @
a677316c
...
...
@@ -98,6 +98,27 @@ void XACCLogger::info(const std::string& msg, MessagePredicate predicate) {
}
}
}
void
XACCLogger
::
warning
(
const
std
::
string
&
msg
,
MessagePredicate
predicate
)
{
if
(
useCout
)
{
if
(
predicate
()
&&
globalPredicate
())
{
if
(
useColor
)
{
std
::
cout
<<
"
\033
[1;33m[XACC Warning] "
+
msg
+
"
\033
[0m
\n
"
;
}
else
{
std
::
cout
<<
"[XACC Warning] "
+
msg
+
"
\n
"
;
}
}
}
else
{
if
(
predicate
()
&&
globalPredicate
())
{
if
(
useColor
)
{
logger
->
info
(
"
\033
[1;33m"
+
msg
+
"
\033
[0m"
);
}
else
{
logger
->
info
(
msg
);
}
}
}
}
void
XACCLogger
::
debug
(
const
std
::
string
&
msg
,
MessagePredicate
predicate
)
{
if
(
useCout
)
{
if
(
predicate
()
&&
globalPredicate
())
{
...
...
@@ -110,7 +131,7 @@ void XACCLogger::debug(const std::string& msg, MessagePredicate predicate) {
}
else
{
if
(
predicate
()
&&
globalPredicate
())
{
if
(
useColor
)
{
logger
->
info
(
"
\033
[1;3
3
m"
+
msg
+
"
\033
[0m"
);
logger
->
info
(
"
\033
[1;3
2
m"
+
msg
+
"
\033
[0m"
);
}
else
{
logger
->
info
(
msg
);
}
...
...
xacc/utils/Utils.hpp
View file @
a677316c
...
...
@@ -134,6 +134,7 @@ public:
}
void
setGlobalLoggerPredicate
(
MessagePredicate
pred
)
{
globalPredicate
=
pred
;}
void
info
(
const
std
::
string
&
msg
,
MessagePredicate
predicate
=
std
::
function
<
bool
(
void
)
>
([]()
{
return
true
;}));
void
warning
(
const
std
::
string
&
msg
,
MessagePredicate
predicate
=
std
::
function
<
bool
(
void
)
>
([]()
{
return
true
;}));
void
debug
(
const
std
::
string
&
msg
,
MessagePredicate
predicate
=
std
::
function
<
bool
(
void
)
>
([]()
{
return
true
;}));
void
error
(
const
std
::
string
&
msg
,
MessagePredicate
predicate
=
std
::
function
<
bool
(
void
)
>
([]()
{
return
true
;}));
};
...
...
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