/*
 * Copyright (C) 2017 Clivern. <https://clivern.com>
 */
package com.clivern.racter.utils;

import java.io.IOException;
import java.util.logging.ConsoleHandler;
import java.util.logging.FileHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Logger Utils Class
 */
public class Log {

	private static final Logger log = Logger.getLogger(Log.class.getName());
	private static Log instance = null;
	private static Handler consoleHandler = null;
	private static Handler fileHandler = null;

	/**
	 * Constructor
	 */
	protected Log() { }

	/**
	 * Get Instance
	 *
	 * @return Log
	 */
	public static Log getInstance() {
	    if(instance == null) {
	        instance = new Log();
	    }
	    return instance;
	}

	/**
	 * Config Logger
	 *
	 * @param  console_handler_status
	 * @param  console_handler_level
	 * @param  file_handler_status
	 * @param  file_handler_level
	 * @param  file_path
	 * @return Log
	 * @throws IOException
	 */
	public static Log config(Boolean console_handler_status, Level console_handler_level, Boolean file_handler_status, Level file_handler_level, String file_path) throws IOException
	{
		if( console_handler_status ){
			consoleHandler = new ConsoleHandler();
			log.addHandler(consoleHandler);
			consoleHandler.setLevel(console_handler_level);
		}

		if( file_handler_status ){
			fileHandler  = new FileHandler(file_path, 50000000, 1, true);
			log.addHandler(fileHandler);
			fileHandler.setLevel(file_handler_level);
		}

		return instance;
	}

	/**
	 * Get Logger
	 *
	 * @return Logger
	 */
	public static Logger getLogger()
	{
		return log;
	}

	public static void fine(String msg)
	{
		log.fine(msg);
	}

	public static void finer(String msg)
	{
		log.finer(msg);
	}

	public static void finest(String msg)
	{
		log.finest(msg);
	}

	public static void info(String msg)
	{
		log.info(msg);
	}

	public static void severe(String msg)
	{
		log.severe(msg);
	}

	public static void warning(String msg)
	{
		log.warning(msg);
	}

	/**
	 * Close File Handler
	 */
	public static void close()
	{
		if( fileHandler != null ){
			fileHandler.close();
		}
	}

}
@@ -1641,24 +1641,75 @@
 rn log;%0A%09%7D%0A%0A
+%09/**%0A%09 * Log Fine Messages%0A%09 *%0A%09 * @param msg%0A%09 */%0A
 %09public stat
@@ -1749,32 +1749,83 @@
 .fine(msg);%0A%09%7D%0A%0A
+%09/**%0A%09 * Log Fine Messages%0A%09 *%0A%09 * @param msg%0A%09 */%0A
 %09public static v
@@ -1863,32 +1863,85 @@
 finer(msg);%0A%09%7D%0A%0A
+%09/**%0A%09 * Log Finest Messages%0A%09 *%0A%09 * @param msg%0A%09 */%0A
 %09public static v
@@ -1981,32 +1981,83 @@
 inest(msg);%0A%09%7D%0A%0A
+%09/**%0A%09 * Log Info Messages%0A%09 *%0A%09 * @param msg%0A%09 */%0A
 %09public static v
@@ -2093,32 +2093,85 @@
 .info(msg);%0A%09%7D%0A%0A
+%09/**%0A%09 * Log Severe Messages%0A%09 *%0A%09 * @param msg%0A%09 */%0A
 %09public static v
@@ -2219,16 +2219,70 @@
 g);%0A%09%7D%0A%0A
+%09/**%0A%09 * Log Warning Messages%0A%09 *%0A%09 * @param msg%0A%09 */%0A
 %09public 

add doc blocks to logger