日志功能封装
This commit is contained in:
30
src/utils/common/logger.ts
Normal file
30
src/utils/common/logger.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import RealtimeTagLogManager = UniNamespace.RealtimeTagLogManager;
|
||||
|
||||
export class Logger {
|
||||
|
||||
private env = uni.getAccountInfoSync().miniProgram.envVersion;
|
||||
private readonly logger: RealtimeTagLogManager;
|
||||
|
||||
constructor() {
|
||||
const logManager = uni.getRealtimeLogManager();
|
||||
this.logger = logManager.tag('suke-mp');
|
||||
}
|
||||
|
||||
info(key: string, value: any) {
|
||||
if(this.env === 'release' || this.env === 'trial') {
|
||||
this.logger.info(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
warn(key: string, value: any) {
|
||||
if(this.env === 'release' || this.env === 'trial') {
|
||||
this.logger.warn(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
error(key: string, value: any) {
|
||||
if(this.env === 'release' || this.env === 'trial') {
|
||||
this.logger.error(key, value);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user