日志功能封装

This commit is contained in:
2024-05-22 18:02:48 +08:00
parent d757f99b5d
commit 68262d0519
5 changed files with 40 additions and 4 deletions

View 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);
}
}
}