MCPcopy Create free account
hub / github.com/DreamSourceLab/DSView / xlog_reset_log_file

Function xlog_reset_log_file

common/log/xlog.c:313–345  ·  view source on GitHub ↗

* Clear the log file, and reopen from the path. */

Source from the content-addressed store, hash-verified

311 * Clear the log file, and reopen from the path.
312*/
313XLOG_API int xlog_reset_log_file(xlog_context* ctx, int receiver_index, const char *file_path)
314{
315 FILE *fh = NULL;
316 int ret = 0;
317
318 if (ctx == NULL || file_path == NULL || *file_path == 0){
319 return -1;
320 }
321
322 pthread_mutex_lock(&ctx->_mutext);
323
324 if (receiver_index < ctx->_count && ctx->_receivers[receiver_index]._file != NULL)
325 {
326 fclose(ctx->_receivers[receiver_index]._file);
327 ctx->_receivers[receiver_index]._file = NULL;
328
329 fh = fopen(file_path, "w+");
330
331 if (fh == NULL){
332 strcpy(ctx->_error, "open file error");
333 ret = -1;
334 }
335 else{
336 ctx->_receivers[receiver_index]._file = fh;
337 }
338 }
339 else{
340 ret = -1;
341 }
342
343 pthread_mutex_unlock(&ctx->_mutext);
344 return ret;
345}
346
347/**
348 * remove a log data receiver,return 0 if success.

Callers 1

dsv_clear_log_fileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected