package net.sourceforge.rtf.usecases.util;

import java.util.Date;

/**
 * 
 * @version 1.0.0
 * @author <a href="mailto:angelo.zerr@gmail.com">Angelo ZERR</a>
 * 
 */
public class UseCaseLog {
	
	private Date lastDate;
	private boolean firstLog = true;
	
	public void logTitle(String message) {
		log(message, true);
	}
	
	public void logBody(String message) {
		log(message, false);
	}
	
	private void log(String message, boolean isTitle) {
		long time = 0;
		if (lastDate == null) {
			lastDate = new Date();
		}
		else {
			Date now = new Date();
			time = now.getTime() - lastDate.getTime();
			lastDate = now;
		}
		if (firstLog) {
			// Header
			System.out.println("TIME    | LOG");
		}
		
		
		if (isTitle) {
			String t = String.valueOf(time) + "        ";
			t = t.substring(0, 8);
			message = t + "| " + message;
		}
			
		System.out.println(message);
		firstLog = false;
	}

}
