Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
cdo
Commits
7e210d68
Commit
7e210d68
authored
Sep 27, 2019
by
Oliver Heidmann
Browse files
added context to debug output
parent
7efb6fe4
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/mpmo.cc
View file @
7e210d68
...
...
@@ -9,15 +9,14 @@ bool verbose = false;
bool
pedantic
=
false
;
bool
exitOnError
=
true
;
int
DebugLevel
=
0
;
void
Debug_
(
const
char
*
p_func
,
int
p_debugScope
,
std
::
function
<
void
()
>
p_function
)
Debug_
(
const
char
*
p_func
,
const
char
*
context
,
int
p_debugScope
,
std
::
function
<
void
()
>
p_function
)
{
(
void
)
p_func
;
if
(
p_debugScope
)
p_function
();
}
void
Debug_
(
const
char
*
p_func
,
std
::
function
<
void
()
>
p_function
)
Debug_
(
const
char
*
p_func
,
const
char
*
context
,
std
::
function
<
void
()
>
p_function
)
{
(
void
)
p_func
;
if
(
DebugLevel
>
0
)
p_function
();
...
...
src/mpmo.h
View file @
7e210d68
...
...
@@ -76,30 +76,31 @@ get_padding(const char *p_func)
return
std
::
string
(
padding_width
-
len
,
' '
);
}
void
Debug_
(
const
char
*
p_func
,
int
p_debugScope
,
std
::
function
<
void
()
>
p_function
);
void
Debug_
(
const
char
*
p_func
,
std
::
function
<
void
()
>
p_function
);
void
Debug_
(
const
char
*
p_func
,
const
char
*
context
,
int
p_debugScope
,
std
::
function
<
void
()
>
p_function
);
void
Debug_
(
const
char
*
p_func
,
const
char
*
context
,
std
::
function
<
void
()
>
p_function
);
template
<
typename
...
Args
>
void
Debug_
(
const
char
*
p_func
,
int
p_debugScope
,
const
std
::
string
&
format
,
Args
const
&
...
args
)
Debug_
(
const
char
*
p_func
,
const
char
*
context
,
int
p_debugScope
,
const
std
::
string
&
format
,
Args
const
&
...
args
)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
#pragma GCC diagnostic ignored "-Wformat-security"
if
(
p_debugScope
)
fprintf
(
stderr
,
(
Cyan
(
"deb
: "
)
+
std
::
string
(
p_func
)
+
get_padding
(
p_func
)
+
format
+
"
\n
"
).
c_str
(),
Argument
(
args
)...);
fprintf
(
stderr
,
(
Cyan
(
context
)
+
"
: "
+
std
::
string
(
p_func
)
+
get_padding
(
p_func
)
+
format
+
"
\n
"
).
c_str
(),
Argument
(
args
)...);
#pragma GCC diagnostic pop
}
template
<
typename
...
Args
>
void
Debug_
(
const
char
*
p_func
,
const
std
::
string
&
format
,
Args
const
&
...
args
)
Debug_
(
const
char
*
p_func
,
const
char
*
context
,
const
std
::
string
&
format
,
Args
const
&
...
args
)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
#pragma GCC diagnostic ignored "-Wformat-security"
if
(
DebugLevel
)
fprintf
(
stderr
,
(
Cyan
(
"deb
: "
)
+
std
::
string
(
p_func
)
+
get_padding
(
p_func
)
+
format
+
"
\n
"
).
c_str
(),
Argument
(
args
)...);
fprintf
(
stderr
,
(
Cyan
(
context
)
+
"
: "
+
std
::
string
(
p_func
)
+
get_padding
(
p_func
)
+
format
+
"
\n
"
).
c_str
(),
Argument
(
args
)...);
#pragma GCC diagnostic pop
}
...
...
@@ -157,7 +158,7 @@ SysError_(const char * func, const std::string &format, Args const &... args) no
#define Verbose(...) Verbose_(__VA_ARGS__)
#ifndef NO_DEBUG
#define Debug(...) MpMO::Debug_(__func__, __VA_ARGS__)
#define Debug(...) MpMO::Debug_(__func__,
CdoOut::getContext(),
__VA_ARGS__)
#else
#define Debug(...)
#endif
...
...
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