-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.js
85 lines (67 loc) · 1.9 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
* @flow
*/
'use strict';
import { NativeModules, NativeAppEventEmitter, DeviceEventEmitter, Platform } from 'react-native';
const XLogBridge = NativeModules.XLogBridge;
const emitter = (Platform.OS === 'android' ? DeviceEventEmitter : NativeAppEventEmitter)
// 以下参数将来可能改为原生穿透过来,待定
const kLevelAll = 0;
const kLevelVerbose = 0;
const kLevelDebug = 1;
const kLevelInfo = 2;
const kLevelWarn = 3;
const kLevelError = 4;
const kLevelFatal = 5;
const kLevelNone = 6;
// 开启xlog, logLevel为上方8种模式
const open = async (): void => {
return await XLogBridge.open();
}
// 关闭xlog
const close = async (): void => {
return await XLogBridge.close();
}
const installUncaughtCrashHandler = async (): void => {
if (!XLogBridge.installUncaughtCrashHandler) {
return;
}
await XLogBridge.installUncaughtCrashHandler();
}
const uninstallUncaughtCrashHandler = async (): void => {
if (!XLogBridge.uninstallUncaughtCrashHandler) {
return;
}
return await XLogBridge.uninstallUncaughtCrashHandler();
}
// 存储用户日志接口
const verbose = async (tag: string, log: string): void => {
return await XLogBridge.log(kLevelVerbose, tag, log);
}
const debug = async (tag: string, log: string): void => {
return await XLogBridge.log(kLevelDebug, tag, log);
}
const info = async (tag: string, log: string): void => {
return await XLogBridge.log(kLevelInfo, tag, log);
}
const warn = async (tag: string, log: string): void => {
return await XLogBridge.log(kLevelWarn, tag, log);
}
const error = async (tag: string, log: string): void => {
return await XLogBridge.log(kLevelError, tag, log);
}
const fatal = async (tag: string, log: string): void => {
return await XLogBridge.log(kLevelFatal, tag, log);
}
module.exports = {
open,
close,
installUncaughtCrashHandler,
uninstallUncaughtCrashHandler,
verbose,
debug,
info,
warn,
error,
fatal,
}