顾海波

【修复】异常

@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 "author": "", 6 "author": "",
7 "license": "", 7 "license": "",
8 "dependencies": { 8 "dependencies": {
9 - "libmarsxlog.so": "file:./src/main/cpp/types/libxlog", 9 + "libmarsxlog.so": "file:./src/main/cpp/types/libmarsxlog",
10 "@ohos/flutter_ohos": "file:./har/flutter.har", 10 "@ohos/flutter_ohos": "file:./har/flutter.har",
11 }, 11 },
12 "modelVersion": "5.0.1", 12 "modelVersion": "5.0.1",
@@ -16,11 +16,15 @@ export class XLog implements LogImp { @@ -16,11 +16,15 @@ export class XLog implements LogImp {
16 } 16 }
17 17
18 appenderClose(): void { 18 appenderClose(): void {
19 - xlog.appenderClose(); 19 + if (xlog) {
  20 + xlog.appenderClose();
  21 + }
20 } 22 }
21 23
22 appenderFlush(logInstancePtr: number, isSync: boolean): void { 24 appenderFlush(logInstancePtr: number, isSync: boolean): void {
23 - xlog.appenderFlush(logInstancePtr, isSync); 25 + if (xlog) {
  26 + xlog.appenderFlush(logInstancePtr, isSync);
  27 + }
24 } 28 }
25 29
26 setAppenderMode(mode: number): void { 30 setAppenderMode(mode: number): void {
@@ -34,7 +38,9 @@ export class XLog implements LogImp { @@ -34,7 +38,9 @@ export class XLog implements LogImp {
34 } 38 }
35 39
36 setConsoleLogOpen(logInstancePtr: number, isOpen: boolean): void { 40 setConsoleLogOpen(logInstancePtr: number, isOpen: boolean): void {
37 - xlog.setConsoleLogOpen(logInstancePtr, isOpen); 41 + if (xlog) {
  42 + xlog.setConsoleLogOpen(logInstancePtr, isOpen);
  43 + }
38 } 44 }
39 45
40 setMaxFileSize(aliveSeconds: number): void { 46 setMaxFileSize(aliveSeconds: number): void {
@@ -46,42 +52,59 @@ export class XLog implements LogImp { @@ -46,42 +52,59 @@ export class XLog implements LogImp {
46 } 52 }
47 53
48 getLogLevel(logInstancePtr: number): number { 54 getLogLevel(logInstancePtr: number): number {
49 - return xlog.getLogLevel(logInstancePtr); 55 + if (xlog) {
  56 + return xlog.getLogLevel(logInstancePtr);
  57 + }
  58 + return LogLevel.LEVEL_VERBOSE;
50 } 59 }
51 60
52 public static appenderOpen(level: number, mode: number, cacheDir: string, logDir: string, nameprefix: string, 61 public static appenderOpen(level: number, mode: number, cacheDir: string, logDir: string, nameprefix: string,
53 cacheDays: number, pubkey: string, compressmode: number, compresslevel: number): void { 62 cacheDays: number, pubkey: string, compressmode: number, compresslevel: number): void {
54 - xlog.appenderOpen(level, mode, logDir, nameprefix, pubkey, compressmode, compresslevel, cacheDir, cacheDays); 63 + if (xlog) {
  64 + xlog.appenderOpen(level, mode, logDir, nameprefix, pubkey, compressmode, compresslevel, cacheDir, cacheDays);
  65 + }
55 } 66 }
56 67
57 logV(logInstancePtr: number, tag: string, filename: string, funcname: string, line: number, pid: number, tid: number, 68 logV(logInstancePtr: number, tag: string, filename: string, funcname: string, line: number, pid: number, tid: number,
58 maintid: number, log: string): void { 69 maintid: number, log: string): void {
59 - xlog.logWrite2(logInstancePtr, LogLevel.LEVEL_VERBOSE, tag, filename, funcname, line, pid, tid, maintid, log); 70 + if (xlog) {
  71 + xlog.logWrite2(logInstancePtr, LogLevel.LEVEL_VERBOSE, tag, filename, funcname, line, pid, tid, maintid, log);
  72 + }
60 } 73 }
61 74
62 logI(logInstancePtr: number, tag: string, filename: string, funcname: string, line: number, pid: number, 75 logI(logInstancePtr: number, tag: string, filename: string, funcname: string, line: number, pid: number,
63 tid: number, maintid: number, log: string): void { 76 tid: number, maintid: number, log: string): void {
64 - xlog.logWrite2(logInstancePtr, LogLevel.LEVEL_INFO, tag, filename, funcname, line, pid, tid, maintid, log); 77 + if (xlog) {
  78 + xlog.logWrite2(logInstancePtr, LogLevel.LEVEL_INFO, tag, filename, funcname, line, pid, tid, maintid, log);
  79 + }
65 } 80 }
66 81
67 logD(logInstancePtr: number, tag: string, filename: string, funcname: string, line: number, pid: number, 82 logD(logInstancePtr: number, tag: string, filename: string, funcname: string, line: number, pid: number,
68 tid: number, maintid: number, log: string): void { 83 tid: number, maintid: number, log: string): void {
69 - xlog.logWrite2(logInstancePtr, LogLevel.LEVEL_DEBUG, tag, filename, funcname, line, pid, tid, maintid, log); 84 + if (xlog) {
  85 + xlog.logWrite2(logInstancePtr, LogLevel.LEVEL_DEBUG, tag, filename, funcname, line, pid, tid, maintid, log);
  86 + }
70 } 87 }
71 88
72 logW(logInstancePtr: number, tag: string, filename: string, funcname: string, line: number, pid: number, 89 logW(logInstancePtr: number, tag: string, filename: string, funcname: string, line: number, pid: number,
73 tid: number, maintid: number, log: string): void { 90 tid: number, maintid: number, log: string): void {
74 - xlog.logWrite2(logInstancePtr, LogLevel.LEVEL_WARNING, tag, filename, funcname, line, pid, tid, maintid, log); 91 + if (xlog) {
  92 + xlog.logWrite2(logInstancePtr, LogLevel.LEVEL_WARNING, tag, filename, funcname, line, pid, tid, maintid, log);
  93 + }
75 } 94 }
76 95
77 logE(logInstancePtr: number, tag: string, filename: string, funcname: string, line: number, pid: number, 96 logE(logInstancePtr: number, tag: string, filename: string, funcname: string, line: number, pid: number,
78 tid: number, maintid: number, log: string): void { 97 tid: number, maintid: number, log: string): void {
79 - xlog.logWrite2(logInstancePtr, LogLevel.LEVEL_ERROR, tag, filename, funcname, line, pid, tid, maintid, log); 98 + if (xlog) {
  99 + xlog.logWrite2(logInstancePtr, LogLevel.LEVEL_ERROR, tag, filename, funcname, line, pid, tid, maintid, log);
  100 + }
80 } 101 }
81 102
82 logF(logInstancePtr: number, tag: string, filename: string, funcname: string, line: number, pid: number, tid: number, 103 logF(logInstancePtr: number, tag: string, filename: string, funcname: string, line: number, pid: number, tid: number,
83 maintid: number, log: string): void { 104 maintid: number, log: string): void {
84 - xlog.logWrite2(logInstancePtr, LogLevel.LEVEL_FATAL, tag, filename, funcname, line, pid, tid, maintid, log); 105 + if (xlog) {
  106 + xlog.logWrite2(logInstancePtr, LogLevel.LEVEL_FATAL, tag, filename, funcname, line, pid, tid, maintid, log);
  107 + }
85 } 108 }
86 } 109 }
87 110