package com.huiju.estateagents.property.log;

import java.util.TimerTask;
import java.util.concurrent.ScheduledThreadPoolExecutor;

/**
 * 日志文件记录
 * @author weiximei
 */
public class LogFileManager {

    // 记录日志的线程池
    private ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(10);

    private LogFileManager() {}

    public static LogFileManager getInstance() {
        return LogSingleton.INSTANCE.getInstance();
    }

    /**
     * 记录日志
     * @param timerTask 任务
     */
    public void executeLog(TimerTask timerTask){
        // 日志记录
        scheduledThreadPoolExecutor.execute(timerTask);
    }

    /**
     * 枚举
     */
    private static enum LogSingleton {
        INSTANCE;

        private LogFileManager logFileManager;
        private LogSingleton() {
            logFileManager = new LogFileManager();
        }

        public LogFileManager getInstance() {
            return logFileManager;
        }

    }
}
