Cleanup logging

If the log knows the filename it is supposed to log to, then we
don't need to have part of that on the init side and the other
part on the flush side. So clean it up so that the caller of
setup_log() provides everything we need. This gets rid of
various ways of ending the log, and opens us up to doing
log flushing mid-run.

Signed-off-by: Jens Axboe <axboe@fb.com>
diff --git a/init.c b/init.c
index 4f8b38d..2017dd3 100644
--- a/init.c
+++ b/init.c
@@ -64,8 +64,6 @@
 int read_only = 0;
 int status_interval = 0;
 
-static int write_lat_log;
-
 static int prev_group_jobs;
 
 unsigned long fio_debug = 0;
@@ -1056,6 +1054,7 @@
 	char fname[PATH_MAX];
 	int numjobs, file_alloced;
 	struct thread_options *o = &td->o;
+	char logname[PATH_MAX + 32];
 
 	/*
 	 * the def_thread is just for options, it's not a real job
@@ -1145,20 +1144,27 @@
 	if (setup_rate(td))
 		goto err;
 
-	if (o->lat_log_file || write_lat_log) {
+	if (o->lat_log_file) {
+		snprintf(logname, sizeof(logname), "%s_lat.log", o->lat_log_file);
 		setup_log(&td->lat_log, o->log_avg_msec, IO_LOG_TYPE_LAT,
-				o->log_offset);
+				o->log_offset, logname);
+		snprintf(logname, sizeof(logname), "%s_slat.log", o->lat_log_file);
 		setup_log(&td->slat_log, o->log_avg_msec, IO_LOG_TYPE_SLAT,
-				o->log_offset);
+				o->log_offset, logname);
+		snprintf(logname, sizeof(logname), "%s_clat.log", o->lat_log_file);
 		setup_log(&td->clat_log, o->log_avg_msec, IO_LOG_TYPE_CLAT,
-				o->log_offset);
+				o->log_offset, logname);
 	}
-	if (o->bw_log_file || write_bw_log)
+	if (o->bw_log_file) {
+		snprintf(logname, sizeof(logname), "%s_bw.log", o->bw_log_file);
 		setup_log(&td->bw_log, o->log_avg_msec, IO_LOG_TYPE_BW,
-				o->log_offset);
-	if (o->iops_log_file)
+				o->log_offset, logname);
+	}
+	if (o->iops_log_file) {
+		snprintf(logname, sizeof(logname), "%s_iops.log", o->iops_log_file);
 		setup_log(&td->iops_log, o->log_avg_msec, IO_LOG_TYPE_IOPS,
-				o->log_offset);
+				o->log_offset, logname);
+	}
 
 	if (!o->name)
 		o->name = strdup(jobname);
@@ -1756,7 +1762,9 @@
 			}
 			break;
 		case 'l':
-			write_lat_log = 1;
+			log_err("fio: --latency-log is deprecated. Use per-job latency log options.\n");
+			do_exit++;
+			exit_val = 1;
 			break;
 		case 'b':
 			write_bw_log = 1;