feat/打印处理
This commit is contained in:
parent
32641c0b20
commit
d80ba28172
|
|
@ -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
|
||||||
|
|
||||||
Loading…
Reference in New Issue