shishuangxi

增加logger日志开关

@@ -22,6 +22,7 @@ export class Logger { @@ -22,6 +22,7 @@ export class Logger {
22 private static domain: number = 0xFF00; 22 private static domain: number = 0xFF00;
23 private static prefix: string = 'SightApp'; 23 private static prefix: string = 'SightApp';
24 private static format: string = `%{public}s, %{public}s`; 24 private static format: string = `%{public}s, %{public}s`;
  25 + static isDebug: boolean = true;
25 26
26 /** 27 /**
27 * constructor. 28 * constructor.
@@ -35,26 +36,44 @@ export class Logger { @@ -35,26 +36,44 @@ export class Logger {
35 } 36 }
36 37
37 static debug(...args: string[]) { 38 static debug(...args: string[]) {
  39 + if(!Logger.isDebug){
  40 + return
  41 + }
38 hilog.debug(Logger.domain, Logger.prefix, Logger.format, args); 42 hilog.debug(Logger.domain, Logger.prefix, Logger.format, args);
39 } 43 }
40 44
41 static info(...args: string[]) { 45 static info(...args: string[]) {
  46 + if(!Logger.isDebug){
  47 + return
  48 + }
42 hilog.info(Logger.domain, Logger.prefix, Logger.format, args); 49 hilog.info(Logger.domain, Logger.prefix, Logger.format, args);
43 } 50 }
44 51
45 static warn(...args: string[]) { 52 static warn(...args: string[]) {
  53 + if(!Logger.isDebug){
  54 + return
  55 + }
46 hilog.warn(Logger.domain, Logger.prefix, Logger.format, args); 56 hilog.warn(Logger.domain, Logger.prefix, Logger.format, args);
47 } 57 }
48 58
49 static error(...args: string[]) { 59 static error(...args: string[]) {
  60 + if(!Logger.isDebug){
  61 + return
  62 + }
50 hilog.error(Logger.domain, Logger.prefix, Logger.format, args); 63 hilog.error(Logger.domain, Logger.prefix, Logger.format, args);
51 } 64 }
52 65
53 static fatal(...args: string[]) { 66 static fatal(...args: string[]) {
  67 + if(!Logger.isDebug){
  68 + return
  69 + }
54 hilog.fatal(Logger.domain, Logger.prefix, Logger.format, args); 70 hilog.fatal(Logger.domain, Logger.prefix, Logger.format, args);
55 } 71 }
56 72
57 static isLoggable(level: LogLevel) { 73 static isLoggable(level: LogLevel) {
  74 + if(!Logger.isDebug){
  75 + return
  76 + }
58 hilog.isLoggable(Logger.domain, Logger.prefix, level); 77 hilog.isLoggable(Logger.domain, Logger.prefix, level);
59 } 78 }
60 } 79 }