X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/08e7455d67920bbd7a87f440d00f2c1e071314a0..a831415e35172e5ffe0b7878c5c2ea6e73f35720:/src/xbt/xbt_log_appender_file.cpp diff --git a/src/xbt/xbt_log_appender_file.cpp b/src/xbt/xbt_log_appender_file.cpp index fd5c34a8e9..e014939097 100644 --- a/src/xbt/xbt_log_appender_file.cpp +++ b/src/xbt/xbt_log_appender_file.cpp @@ -12,6 +12,7 @@ #include #include #include +#include static void append_file(const s_xbt_log_appender_t* this_, const char* str) { @@ -40,8 +41,7 @@ xbt_log_appender_t xbt_log_appender_file_new(const char* arg) res->do_append = &append_file; res->free_ = &free_; res->data = static_cast(fopen(arg, "w")); - if (res->data == nullptr) - xbt_die("Cannot open file: %s: %s", arg, strerror(errno)); + xbt_assert(res->data != nullptr, "Cannot open file: %s: %s", arg, strerror(errno)); return res; } @@ -61,8 +61,7 @@ static void open_append2_file(xbt_log_append2_file_t data){ //Roll if (!data->file) { data->file= fopen(data->filename, "w"); - if (data->file == nullptr) - xbt_die("Cannot open file: %s: %s", data->filename, strerror(errno)); + xbt_assert(data->file != nullptr, "Cannot open file: %s: %s", data->filename, strerror(errno)); } else { fputs(APPEND2_END_TOKEN_CLEAR,data->file); fseek(data->file,0,SEEK_SET); @@ -80,8 +79,7 @@ static void open_append2_file(xbt_log_append2_file_t data){ std::string newname = pre + std::to_string(data->count) + post; data->count++; data->file = fopen(newname.c_str(), "w"); - if (data->file == nullptr) - xbt_die("Cannot open file: %s: %s", newname.c_str(), strerror(errno)); + xbt_assert(data->file != nullptr, "Cannot open file: %s: %s", newname.c_str(), strerror(errno)); xbt_free(pre); } }