- 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 == NULL)
- xbt_die("Cannot open file: %s: %s", arg, strerror(errno));
- } else {
- res->data = (void *) stderr;
- }
+xbt_log_appender_t xbt_log_appender_file_new(const char* arg)
+{
+ if (arg == nullptr)
+ return xbt_log_appender_stream(stderr);
+ auto* res = xbt_new0(s_xbt_log_appender_t, 1);
+ res->do_append = &append_file;
+ res->free_ = &free_;
+ res->data = static_cast<void*>(fopen(arg, "w"));
+ xbt_assert(res->data != nullptr, "Cannot open file: %s: %s", arg, strerror(errno));