+static int open_new_logfile(struct dataparser_struct *dt)
+{
+ char path[2048];
+ struct tm *tm;
+ time_t cur_time = time(NULL);
+
+ tm = localtime(&cur_time);
+ strftime(path, sizeof(path), dt->log_path, tm);
+
+ pr_debug("Opening %s for writing the log file\n", path);
+
+ dt->outfd = open(path, O_CREAT | O_APPEND | O_WRONLY, 0664);
+ if (dt->outfd < 0) {
+ pr_err("Failed to open file %s for writing: %m\n",
+ path);
+ return -1;
+ }
+
+ return 0;
+}
+