/*
 * @Descripttion: 
 * @version: 1.0.0
 * @Author: YeeChan
 * @Date: 2020-07-09 18:54:34
 */

/**
 * 日志
 */
export class LogUtils {
    /** log状态 */
    private static _logStatus_custom: boolean = true;

    /** 设置日志状态 */
    public static setLogStatus(flag: boolean): void {
        LogUtils._logStatus_custom = flag;
    }

    /**调试日志*/
    public static log_custom(message?: any, ...optionalParams: any[]): void {
        if (!LogUtils._logStatus_custom) { return; }
        console.log("[log][", LogUtils.getFullTime_custom(), "]", ":", message, ...optionalParams);
    }

    /**输出日志*/
    public static info_custom(message?: any, ...optionalParams: any[]): void {
        if (!LogUtils._logStatus_custom) { return; }
        console.debug("[debug][", LogUtils.getFullTime_custom(), "]", ":", message, ...optionalParams);
    }


    /**警告日志*/
    public static warn_custom(message?: any, ...optionalParams: any[]): void {
        if (!LogUtils._logStatus_custom) { return; }
        console.warn("[warn][", LogUtils.getFullTime_custom(), "]", ":", message, ...optionalParams);
    }


    /**错误日志*/
    public static error_custom(message?: any, ...optionalParams: any[]): void {
        if (!LogUtils._logStatus_custom) { return; }
        console.error("[error][", LogUtils.getFullTime_custom(), "]", ":", message, ...optionalParams);
    }

    /**网络日志*/
    public static networkLog_custom(message?: any, ...optionalParams: any[]): void {
        if (!LogUtils._logStatus_custom) { return; }
        console.log("[network][", LogUtils.getFullTime_custom(), "]", ":", message, ...optionalParams);
    }
    /**网络错误日志*/
    public static networkError_custom(message?: any, ...optionalParams: any[]): void {
        if (!LogUtils._logStatus_custom) { return; }
        console.error("[network][", LogUtils.getFullTime_custom(), "]", ":", message, ...optionalParams);
    }

    /** 获取完全时间 */
    public static getFullTime_custom(): string {
        let date = new Date();
        return date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds() + "-" + date.getMilliseconds();
    }
}

//导出
(<any>window).LogUtils = LogUtils;