From: Arnaud Giersch Date: Tue, 26 Mar 2019 21:25:19 +0000 (+0100) Subject: [sonar] Use a logger for help messages. X-Git-Tag: v3.22.2~192 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/01d2ec474c4c1828c229830ba4e4961de5f0527d?hp=6519b80100b8e2258b68cf6a65ea2d85ecc69a60 [sonar] Use a logger for help messages. --- diff --git a/include/xbt/log.h b/include/xbt/log.h index a6df1231d9..a65699c37e 100644 --- a/include/xbt/log.h +++ b/include/xbt/log.h @@ -644,5 +644,11 @@ extern xbt_log_layout_t xbt_log_default_layout; */ #define XBT_HERE(...) XBT_LOG(xbt_log_priority_trace, "-- was here" __VA_ARGS__) +/** @ingroup XBT_log + * @hideinitializer + * @brief Log help messages through category xbt.xbt_help. + */ +#define XBT_HELP(...) XBT_CINFO(xbt_help, __VA_ARGS__) + SG_END_DECL() #endif /* ! _XBT_LOG_H_ */ diff --git a/include/xbt/sysdep.h b/include/xbt/sysdep.h index 45d9320da1..f24b717a64 100644 --- a/include/xbt/sysdep.h +++ b/include/xbt/sysdep.h @@ -49,8 +49,10 @@ XBT_ATTRIB_NORETURN XBT_PUBLIC void xbt_abort(void); #ifdef XBT_LOG_LOCALLY_DEFINE_XBT_CHANNEL XBT_LOG_NEW_CATEGORY(xbt, "All XBT categories (simgrid toolbox)"); +XBT_LOG_NEW_SUBCATEGORY(xbt_help, xbt, "Help messages"); #else XBT_LOG_EXTERNAL_CATEGORY(xbt); +XBT_LOG_EXTERNAL_CATEGORY(xbt_help); #endif /** @addtogroup XBT_syscall diff --git a/src/instr/instr_config.cpp b/src/instr/instr_config.cpp index c6cdff7c5f..773b0ce502 100644 --- a/src/instr/instr_config.cpp +++ b/src/instr/instr_config.cpp @@ -301,15 +301,15 @@ static void print_line(const char* option, const char* desc, const char* longdes std::string str = std::string("--cfg=") + option + " "; int len = str.size(); - printf("%s%*.*s %s\n", str.c_str(), 30 - len, 30 - len, "", desc); + XBT_HELP("%s%*.*s %s", str.c_str(), 30 - len, 30 - len, "", desc); if (longdesc != nullptr) { - printf ("%s\n\n", longdesc); + XBT_HELP("%s\n", longdesc); } } void TRACE_help() { - printf("Description of the tracing options accepted by this simulator:\n\n"); + XBT_HELP("Description of the tracing options accepted by this simulator:\n"); print_line(OPT_TRACING_SMPI, "Trace the MPI Interface (SMPI)", " This option only has effect if this simulator is SMPI-based. Traces the MPI\n" " interface and generates a trace that can be analyzed using Gantt-like\n" diff --git a/src/simgrid/sg_config.cpp b/src/simgrid/sg_config.cpp index 29ed3104fb..816d265631 100644 --- a/src/simgrid/sg_config.cpp +++ b/src/simgrid/sg_config.cpp @@ -63,39 +63,36 @@ static void sg_config_cmd_line(int *argc, char **argv) sg_version(); shall_exit = true; } else if (parse_args && (not strcmp(argv[i], "--cfg-help") || not strcmp(argv[i], "--help"))) { - printf("Description of the configuration accepted by this simulator:\n"); + XBT_HELP("Description of the configuration accepted by this simulator:"); simgrid::config::help(); - printf( - "\n" - "Each of these configurations can be used by adding\n" - " --cfg=