feat/打印处理

This commit is contained in:
季万俊 2026-01-13 16:44:20 +08:00
parent 32641c0b20
commit d80ba28172
1 changed files with 84 additions and 0 deletions

84
src/utils/logger.js Normal file
View File

@ -0,0 +1,84 @@
/*
* @Author: 系统生成
* @Date: 2025-01-XX
* @Description: 日志工具 - 根据环境变量控制日志输出
*/
// 判断是否为生产环境
const isProduction = import.meta.env.MODE === 'production' || import.meta.env.PROD
// 日志工具类
const logger = {
/**
* 普通日志生产环境不输出
*/
log(...args) {
if (!isProduction) {
console.log(...args)
}
},
/**
* 警告日志生产环境不输出
*/
warn(...args) {
if (!isProduction) {
console.warn(...args)
}
},
/**
* 错误日志始终输出
*/
error(...args) {
console.error(...args)
},
/**
* 信息日志生产环境不输出
*/
info(...args) {
if (!isProduction) {
console.info(...args)
}
},
/**
* 调试日志生产环境不输出
*/
debug(...args) {
if (!isProduction) {
console.debug(...args)
}
},
/**
* 分组日志生产环境不输出
*/
group(...args) {
if (!isProduction) {
console.group(...args)
}
},
/**
* 结束分组生产环境不输出
*/
groupEnd() {
if (!isProduction) {
console.groupEnd()
}
},
/**
* 表格日志生产环境不输出
*/
table(...args) {
if (!isProduction) {
console.table(...args)
}
}
}
export default logger