我智商爆棚
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.2 KiB

4 weeks ago
/*
* @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;