Skip to content

Commit d0dc621

Browse files
Merge pull request #6709 from ggouaillardet/topic/opal_output_verbose
opal/util: revamp opal_output_verbose()
2 parents 07c722e + d2876fa commit d0dc621

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

opal/util/output.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Copyright (c) 2007-2008 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
1515
* reserved.
16-
* Copyright (c) 2015 Research Organization for Information Science
16+
* Copyright (c) 2015-2019 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
1818
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1919
* Copyright (c) 2017-2018 Intel, Inc. All rights reserved.
@@ -388,17 +388,12 @@ void opal_output(int output_id, const char *format, ...)
388388

389389

390390
/*
391-
* Send a message to a stream if the verbose level is high enough
391+
* Check whether the verbose level is high enough for the given stream
392392
*/
393-
void opal_output_verbose(int level, int output_id, const char *format, ...)
393+
bool opal_output_check_verbosity(int level, int output_id)
394394
{
395-
if (output_id >= 0 && output_id < OPAL_OUTPUT_MAX_STREAMS &&
396-
info[output_id].ldi_verbose_level >= level) {
397-
va_list arglist;
398-
va_start(arglist, format);
399-
output(output_id, format, arglist);
400-
va_end(arglist);
401-
}
395+
return (output_id >= 0 && output_id < OPAL_OUTPUT_MAX_STREAMS &&
396+
info[output_id].ldi_verbose_level >= level);
402397
}
403398

404399

opal/util/output.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
1515
* Copyright (c) 2018 Triad National Security, LLC. All rights
1616
* reserved.
17+
* Copyright (c) 2019 Research Organization for Information Science
18+
* and Technology (RIST). All rights reserved.
1719
* $COPYRIGHT$
1820
*
1921
* Additional copyrights may follow
@@ -402,8 +404,14 @@ struct opal_output_stream_t {
402404
*
403405
* @see opal_output_set_verbosity()
404406
*/
405-
OPAL_DECLSPEC void opal_output_verbose(int verbose_level, int output_id,
406-
const char *format, ...) __opal_attribute_format__(__printf__, 3, 4);
407+
#define opal_output_verbose(verbose_level, output_id, ...) \
408+
do { \
409+
if (opal_output_check_verbosity(verbose_level, output_id)) { \
410+
opal_output(output_id, __VA_ARGS__); \
411+
} \
412+
} while(0)
413+
414+
OPAL_DECLSPEC bool opal_output_check_verbosity(int verbose_level, int output_id);
407415

408416
/**
409417
* Same as opal_output_verbose(), but takes a va_list form of varargs.

0 commit comments

Comments
 (0)