SimGrid (3.23) NOT RELEASED (Release Target: June 21. 2019, 15:54 UTC)
XBT:
+ - New log appenders: stdout and stderr. Use stdout for xbt_help.
- Drop xbt_dict_dump.
Fixed bugs (GH=GitHub; FG=FramaGit):
#include <stdarg.h>
#include <stddef.h> /* NULL */
+#include <stdio.h> /* FILE */
#include <xbt/misc.h>
SG_BEGIN_DECL()
/**@brief Log priorities
*/
XBT_PUBLIC xbt_log_layout_t xbt_log_layout_simple_new(const char* arg);
XBT_PUBLIC xbt_log_layout_t xbt_log_layout_format_new(const char* arg);
+XBT_PUBLIC xbt_log_appender_t xbt_log_appender_stream(FILE* f);
XBT_PUBLIC xbt_log_appender_t xbt_log_appender_file_new(const char* arg);
XBT_PUBLIC xbt_log_appender_t xbt_log_appender2_file_new(const char* arg, int roll);
which were already created (damnit. Too slow little beetle) */
void xbt_log_preinit(void)
{
- xbt_log_default_appender = xbt_log_appender_file_new(nullptr);
+ xbt_log_default_appender = xbt_log_appender_stream(stderr);
xbt_log_default_layout = xbt_log_layout_simple_new(nullptr);
_XBT_LOGV(XBT_LOG_ROOT_CAT).appender = xbt_log_default_appender;
_XBT_LOGV(XBT_LOG_ROOT_CAT).layout = xbt_log_default_layout;
int j = 1;
int parse_args = 1; // Stop parsing the parameters once we found '--'
- xbt_log_control_set("xbt_help.threshold:VERBOSE xbt_help.fmt:%m%n");
+ xbt_log_control_set("xbt_help.app:stdout xbt_help.threshold:VERBOSE xbt_help.fmt:%m%n");
/* Set logs and init log submodule */
for (int i = 1; i < *argc; i++) {
set.appender = xbt_log_appender2_file_new(value + 9, 1);
} else if (strncmp(value, "splitfile:", 10) == 0) {
set.appender = xbt_log_appender2_file_new(value + 10, 0);
+ } else if (strcmp(value, "stderr") == 0) {
+ set.appender = xbt_log_appender_stream(stderr);
+ } else if (strcmp(value, "stdout") == 0) {
+ set.appender = xbt_log_appender_stream(stdout);
} else {
THROWF(arg_error, 0, "Unknown appender log type: '%s'", value);
}
fputs(str, (FILE *) this_->data);
}
-static void free_(xbt_log_appender_t this_) {
- if (this_->data != stderr)
- fclose(static_cast<FILE*>(this_->data));
+static void free_(xbt_log_appender_t this_)
+{
+ fclose(static_cast<FILE*>(this_->data));
+}
+
+xbt_log_appender_t xbt_log_appender_stream(FILE* f)
+{
+ xbt_log_appender_t res = xbt_new0(s_xbt_log_appender_t, 1);
+ res->do_append = &append_file;
+ res->free_ = nullptr;
+ res->data = static_cast<void*>(f);
+ return res;
}
xbt_log_appender_t xbt_log_appender_file_new(const char* arg)
{
+ if (arg == nullptr)
+ return xbt_log_appender_stream(stderr);
xbt_log_appender_t res = xbt_new0(s_xbt_log_appender_t, 1);
res->do_append = &append_file;
res->free_ = &free_;
- if (arg) {
- res->data = (void *) fopen(arg, "w");
- if (res->data == nullptr)
- xbt_die("Cannot open file: %s: %s", arg, strerror(errno));
- } else {
- res->data = (void *) stderr;
- }
+ res->data = static_cast<void*>(fopen(arg, "w"));
+ if (res->data == nullptr)
+ xbt_die("Cannot open file: %s: %s", arg, strerror(errno));
return res;
}