@maplibre/maplibre-react-native 11.0.0-alpha.17 → 11.0.0-alpha.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/org/maplibre/reactnative/MLRNPackage.kt +6 -6
- package/android/src/main/java/org/maplibre/reactnative/modules/MLRNLogModule.kt +99 -0
- package/ios/modules/logging/MLRNLogModule.h +10 -0
- package/ios/modules/logging/MLRNLogModule.mm +39 -0
- package/ios/modules/logging/MLRNLogging.h +15 -2
- package/ios/modules/logging/MLRNLogging.m +22 -55
- package/lib/commonjs/components/map-view/MapView.js +3 -3
- package/lib/commonjs/components/map-view/MapView.js.map +1 -1
- package/lib/commonjs/index.js +4 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/modules/log/LogManager.js +99 -0
- package/lib/commonjs/modules/log/LogManager.js.map +1 -0
- package/lib/commonjs/modules/log/NativeLogModule.js +9 -0
- package/lib/commonjs/modules/log/NativeLogModule.js.map +1 -0
- package/lib/module/components/map-view/MapView.js +3 -3
- package/lib/module/components/map-view/MapView.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/modules/log/LogManager.js +96 -0
- package/lib/module/modules/log/LogManager.js.map +1 -0
- package/lib/module/modules/log/NativeLogModule.js +5 -0
- package/lib/module/modules/log/NativeLogModule.js.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +1 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/log/LogManager.d.ts +45 -0
- package/lib/typescript/commonjs/src/modules/log/LogManager.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/log/NativeLogModule.d.ts +13 -0
- package/lib/typescript/commonjs/src/modules/log/NativeLogModule.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +1 -1
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/log/LogManager.d.ts +45 -0
- package/lib/typescript/module/src/modules/log/LogManager.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/log/NativeLogModule.d.ts +13 -0
- package/lib/typescript/module/src/modules/log/NativeLogModule.d.ts.map +1 -0
- package/package.json +2 -1
- package/src/components/map-view/MapView.tsx +3 -3
- package/src/index.ts +1 -1
- package/src/modules/log/LogManager.ts +114 -0
- package/src/modules/log/NativeLogModule.ts +16 -0
- package/android/src/main/java/org/maplibre/reactnative/modules/MLRNLogging.java +0 -140
- package/lib/commonjs/modules/Logger.js +0 -112
- package/lib/commonjs/modules/Logger.js.map +0 -1
- package/lib/module/modules/Logger.js +0 -107
- package/lib/module/modules/Logger.js.map +0 -1
- package/lib/typescript/commonjs/src/modules/Logger.d.ts +0 -49
- package/lib/typescript/commonjs/src/modules/Logger.d.ts.map +0 -1
- package/lib/typescript/module/src/modules/Logger.d.ts +0 -49
- package/lib/typescript/module/src/modules/Logger.d.ts.map +0 -1
- package/src/modules/Logger.ts +0 -127
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Logger = void 0;
|
|
7
|
-
var _reactNative = require("react-native");
|
|
8
|
-
const MLRNLogging = _reactNative.NativeModules.MLRNLogging;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Supported log levels
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* This callback is displayed as part of the Requester class.
|
|
16
|
-
* @param {object} log
|
|
17
|
-
* @param {string} log.message - the message of the log
|
|
18
|
-
* @param {string} log.level - log level
|
|
19
|
-
* @param {string} log.tag - optional tag used on android
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
class Logger {
|
|
23
|
-
static instance = null;
|
|
24
|
-
static sharedInstance() {
|
|
25
|
-
if (this.instance === null) {
|
|
26
|
-
this.instance = new Logger();
|
|
27
|
-
}
|
|
28
|
-
return this.instance;
|
|
29
|
-
}
|
|
30
|
-
constructor() {
|
|
31
|
-
this.loggerEmitter = new _reactNative.NativeEventEmitter(MLRNLogging);
|
|
32
|
-
this.startedCount = 0;
|
|
33
|
-
this.logCallback = null;
|
|
34
|
-
this.subscription = null;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Set custom logger function
|
|
39
|
-
*
|
|
40
|
-
* @param logCallback - callback taking a log object as param. If callback return falsy value then default logging
|
|
41
|
-
* will take place.
|
|
42
|
-
*/
|
|
43
|
-
static setLogCallback(logCallback) {
|
|
44
|
-
this.sharedInstance().setLogCallback(logCallback);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Set custom logger function
|
|
49
|
-
*
|
|
50
|
-
* @param logCallback - callback taking a log object as param. If callback return falsy value then default logging
|
|
51
|
-
* will take place.
|
|
52
|
-
*/
|
|
53
|
-
setLogCallback(logCallback) {
|
|
54
|
-
this.logCallback = logCallback;
|
|
55
|
-
}
|
|
56
|
-
static setLogLevel(level) {
|
|
57
|
-
MLRNLogging.setLogLevel(level);
|
|
58
|
-
}
|
|
59
|
-
start() {
|
|
60
|
-
if (this.startedCount === 0) {
|
|
61
|
-
this.subscribe();
|
|
62
|
-
}
|
|
63
|
-
this.startedCount += 1;
|
|
64
|
-
}
|
|
65
|
-
stop() {
|
|
66
|
-
this.startedCount -= 1;
|
|
67
|
-
if (this.startedCount === 0) {
|
|
68
|
-
this.unsubscribe();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
subscribe() {
|
|
72
|
-
this.subscription = this.loggerEmitter.addListener("LogEvent", log => {
|
|
73
|
-
this.onLog(log);
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
unsubscribe() {
|
|
77
|
-
if (this.subscription) {
|
|
78
|
-
this.subscription.remove();
|
|
79
|
-
this.subscription = null;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
effectiveLevel({
|
|
83
|
-
level,
|
|
84
|
-
message,
|
|
85
|
-
tag
|
|
86
|
-
}) {
|
|
87
|
-
if (level === "warning") {
|
|
88
|
-
if (tag === "Mbgl-HttpRequest" && message.startsWith("Request failed due to a permanent error: Canceled")) {
|
|
89
|
-
// this seems to happening too much to show a warning every time
|
|
90
|
-
return "info";
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return level;
|
|
94
|
-
}
|
|
95
|
-
onLog(log) {
|
|
96
|
-
if (!this.logCallback || !this.logCallback(log)) {
|
|
97
|
-
const {
|
|
98
|
-
message
|
|
99
|
-
} = log;
|
|
100
|
-
const level = this.effectiveLevel(log);
|
|
101
|
-
if (level === "error") {
|
|
102
|
-
console.error("MapLibre error", message, log);
|
|
103
|
-
} else if (level === "warning") {
|
|
104
|
-
console.warn("MapLibre warning", message, log);
|
|
105
|
-
} else {
|
|
106
|
-
console.log(`MapLibre [${level}]`, message, log);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
exports.Logger = Logger;
|
|
112
|
-
//# sourceMappingURL=Logger.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","MLRNLogging","NativeModules","Logger","instance","sharedInstance","constructor","loggerEmitter","NativeEventEmitter","startedCount","logCallback","subscription","setLogCallback","setLogLevel","level","start","subscribe","stop","unsubscribe","addListener","log","onLog","remove","effectiveLevel","message","tag","startsWith","console","error","warn","exports"],"sourceRoot":"../../../src","sources":["modules/Logger.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAKA,MAAMC,WAAW,GAAGC,0BAAa,CAACD,WAAW;;AAE7C;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGO,MAAME,MAAM,CAAC;EAClB,OAAOC,QAAQ,GAAkB,IAAI;EAErC,OAAOC,cAAcA,CAAA,EAAW;IAC9B,IAAI,IAAI,CAACD,QAA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E;MACrB,IAAI,CAACA,YAAY,CAACW,MAAM,CAAC,CAAC;MAC1B,IAAI,CAACX,YAAY,GAAG,IAAI;IAC1B;EACF;EAEAY,cAAcA,CAAC;IAAET,KAAK;IAAEU,OAAO;IAAEC;EAAS,CAAC,EAAY;IACrD,IAAIX,KAAK,KAAK,SAAS,EAAE;MACvB,IACEW,GAAG,KAAK,kBAAkB,IAC1BD,OAAO,CAACE,UAAU,CAAC,mDAAmD,CAAC,EACvE;QACA;QACA,OAAO,MAAM;MACf;IACF;IACA,OAAOZ,KAAK;EACd;EAEAO,KAAKA,CAACD,GAAQ,EAAQ;IACpB,IAAI,CAAC,IAAI,CAACV,WAAW,IAAI,CAAC,IAAI,CAACA,WAAW,CAACU,GAAG,CAAC,EAAE;MAC/C,MAAM;QAAEI;MAAQ,CAAC,GAAGJ,GAAG;MACvB,MAAMN,KAAK,GAAG,IAAI,CAACS,cAAc,CAACH,GAAG,CAAC;MACtC,IAAIN,KAAK,KAAK,OAAO,EAAE;QACrBa,OAAO,CAACC,KAAK,CAAC,gBAAgB,EAAEJ,OAAO,EAAEJ,GAAG,CAAC;MAC/C,CAAC,MAAM,IAAIN,KAAK,KAAK,SAAS,EAAE;QAC9Ba,OAAO,CAACE,IAAI,CAAC,kBAAkB,EAAEL,OAAO,EAAEJ,GAAG,CAAC;MAChD,CAAC,MAAM;QACLO,OAAO,CAACP,GAAG,CAAC,aAAaN,KAAK,GAAG,EAAEU,OAAO,EAAEJ,GAAG,CAAC;MAClD;IACF;EACF;AACF;AAACU,OAAA,CAAA3B,MAAA,GAAAA,MAAA","ignoreList":[]}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { NativeEventEmitter, NativeModules } from "react-native";
|
|
4
|
-
const MLRNLogging = NativeModules.MLRNLogging;
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Supported log levels
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* This callback is displayed as part of the Requester class.
|
|
12
|
-
* @param {object} log
|
|
13
|
-
* @param {string} log.message - the message of the log
|
|
14
|
-
* @param {string} log.level - log level
|
|
15
|
-
* @param {string} log.tag - optional tag used on android
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
export class Logger {
|
|
19
|
-
static instance = null;
|
|
20
|
-
static sharedInstance() {
|
|
21
|
-
if (this.instance === null) {
|
|
22
|
-
this.instance = new Logger();
|
|
23
|
-
}
|
|
24
|
-
return this.instance;
|
|
25
|
-
}
|
|
26
|
-
constructor() {
|
|
27
|
-
this.loggerEmitter = new NativeEventEmitter(MLRNLogging);
|
|
28
|
-
this.startedCount = 0;
|
|
29
|
-
this.logCallback = null;
|
|
30
|
-
this.subscription = null;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Set custom logger function
|
|
35
|
-
*
|
|
36
|
-
* @param logCallback - callback taking a log object as param. If callback return falsy value then default logging
|
|
37
|
-
* will take place.
|
|
38
|
-
*/
|
|
39
|
-
static setLogCallback(logCallback) {
|
|
40
|
-
this.sharedInstance().setLogCallback(logCallback);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Set custom logger function
|
|
45
|
-
*
|
|
46
|
-
* @param logCallback - callback taking a log object as param. If callback return falsy value then default logging
|
|
47
|
-
* will take place.
|
|
48
|
-
*/
|
|
49
|
-
setLogCallback(logCallback) {
|
|
50
|
-
this.logCallback = logCallback;
|
|
51
|
-
}
|
|
52
|
-
static setLogLevel(level) {
|
|
53
|
-
MLRNLogging.setLogLevel(level);
|
|
54
|
-
}
|
|
55
|
-
start() {
|
|
56
|
-
if (this.startedCount === 0) {
|
|
57
|
-
this.subscribe();
|
|
58
|
-
}
|
|
59
|
-
this.startedCount += 1;
|
|
60
|
-
}
|
|
61
|
-
stop() {
|
|
62
|
-
this.startedCount -= 1;
|
|
63
|
-
if (this.startedCount === 0) {
|
|
64
|
-
this.unsubscribe();
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
subscribe() {
|
|
68
|
-
this.subscription = this.loggerEmitter.addListener("LogEvent", log => {
|
|
69
|
-
this.onLog(log);
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
unsubscribe() {
|
|
73
|
-
if (this.subscription) {
|
|
74
|
-
this.subscription.remove();
|
|
75
|
-
this.subscription = null;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
effectiveLevel({
|
|
79
|
-
level,
|
|
80
|
-
message,
|
|
81
|
-
tag
|
|
82
|
-
}) {
|
|
83
|
-
if (level === "warning") {
|
|
84
|
-
if (tag === "Mbgl-HttpRequest" && message.startsWith("Request failed due to a permanent error: Canceled")) {
|
|
85
|
-
// this seems to happening too much to show a warning every time
|
|
86
|
-
return "info";
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return level;
|
|
90
|
-
}
|
|
91
|
-
onLog(log) {
|
|
92
|
-
if (!this.logCallback || !this.logCallback(log)) {
|
|
93
|
-
const {
|
|
94
|
-
message
|
|
95
|
-
} = log;
|
|
96
|
-
const level = this.effectiveLevel(log);
|
|
97
|
-
if (level === "error") {
|
|
98
|
-
console.error("MapLibre error", message, log);
|
|
99
|
-
} else if (level === "warning") {
|
|
100
|
-
console.warn("MapLibre warning", message, log);
|
|
101
|
-
} else {
|
|
102
|
-
console.log(`MapLibre [${level}]`, message, log);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
//# sourceMappingURL=Logger.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["NativeEventEmitter","NativeModules","MLRNLogging","Logger","instance","sharedInstance","constructor","loggerEmitter","startedCount","logCallback","subscription","setLogCallback","setLogLevel","level","start","subscribe","stop","unsubscribe","addListener","log","onLog","remove","effectiveLevel","message","tag","startsWith","console","error","warn"],"sourceRoot":"../../../src","sources":["modules/Logger.ts"],"mappings":";;AAAA,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 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Supported log levels
|
|
3
|
-
*/
|
|
4
|
-
export type LogLevel = "error" | "warning" | "info" | "debug" | "verbose";
|
|
5
|
-
interface Log {
|
|
6
|
-
message: string;
|
|
7
|
-
level: LogLevel;
|
|
8
|
-
tag?: string;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* This callback is displayed as part of the Requester class.
|
|
12
|
-
* @param {object} log
|
|
13
|
-
* @param {string} log.message - the message of the log
|
|
14
|
-
* @param {string} log.level - log level
|
|
15
|
-
* @param {string} log.tag - optional tag used on android
|
|
16
|
-
*/
|
|
17
|
-
type LogCallback = (log: Log) => boolean;
|
|
18
|
-
export declare class Logger {
|
|
19
|
-
static instance: Logger | null;
|
|
20
|
-
static sharedInstance(): Logger;
|
|
21
|
-
private loggerEmitter;
|
|
22
|
-
private startedCount;
|
|
23
|
-
private logCallback;
|
|
24
|
-
private subscription;
|
|
25
|
-
constructor();
|
|
26
|
-
/**
|
|
27
|
-
* Set custom logger function
|
|
28
|
-
*
|
|
29
|
-
* @param logCallback - callback taking a log object as param. If callback return falsy value then default logging
|
|
30
|
-
* will take place.
|
|
31
|
-
*/
|
|
32
|
-
static setLogCallback(logCallback: LogCallback): void;
|
|
33
|
-
/**
|
|
34
|
-
* Set custom logger function
|
|
35
|
-
*
|
|
36
|
-
* @param logCallback - callback taking a log object as param. If callback return falsy value then default logging
|
|
37
|
-
* will take place.
|
|
38
|
-
*/
|
|
39
|
-
setLogCallback(logCallback: LogCallback): void;
|
|
40
|
-
static setLogLevel(level: LogLevel): void;
|
|
41
|
-
start(): void;
|
|
42
|
-
stop(): void;
|
|
43
|
-
subscribe(): void;
|
|
44
|
-
unsubscribe(): void;
|
|
45
|
-
effectiveLevel({ level, message, tag }: Log): LogLevel;
|
|
46
|
-
onLog(log: Log): void;
|
|
47
|
-
}
|
|
48
|
-
export {};
|
|
49
|
-
//# sourceMappingURL=Logger.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../../../../src/modules/Logger.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;AAE1E,UAAU,GAAG;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,QAAQ,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;;GAMG;AACH,KAAK,WAAW,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC;AAEzC,qBAAa,MAAM;IACjB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAEtC,MAAM,CAAC,cAAc,IAAI,MAAM;IAO/B,OAAO,CAAC,aAAa,CAAqB;IAC1C,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,WAAW,CAAqB;IACxC,OAAO,CAAC,YAAY,CAA6B;;IASjD;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAIrD;;;;;OAKG;IACH,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAI9C,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAIzC,KAAK,IAAI,IAAI;IAOb,IAAI,IAAI,IAAI;IAOZ,SAAS,IAAI,IAAI;IAMjB,WAAW,IAAI,IAAI;IAOnB,cAAc,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,GAAG,GAAG,QAAQ;IAatD,KAAK,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI;CAatB"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Supported log levels
|
|
3
|
-
*/
|
|
4
|
-
export type LogLevel = "error" | "warning" | "info" | "debug" | "verbose";
|
|
5
|
-
interface Log {
|
|
6
|
-
message: string;
|
|
7
|
-
level: LogLevel;
|
|
8
|
-
tag?: string;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* This callback is displayed as part of the Requester class.
|
|
12
|
-
* @param {object} log
|
|
13
|
-
* @param {string} log.message - the message of the log
|
|
14
|
-
* @param {string} log.level - log level
|
|
15
|
-
* @param {string} log.tag - optional tag used on android
|
|
16
|
-
*/
|
|
17
|
-
type LogCallback = (log: Log) => boolean;
|
|
18
|
-
export declare class Logger {
|
|
19
|
-
static instance: Logger | null;
|
|
20
|
-
static sharedInstance(): Logger;
|
|
21
|
-
private loggerEmitter;
|
|
22
|
-
private startedCount;
|
|
23
|
-
private logCallback;
|
|
24
|
-
private subscription;
|
|
25
|
-
constructor();
|
|
26
|
-
/**
|
|
27
|
-
* Set custom logger function
|
|
28
|
-
*
|
|
29
|
-
* @param logCallback - callback taking a log object as param. If callback return falsy value then default logging
|
|
30
|
-
* will take place.
|
|
31
|
-
*/
|
|
32
|
-
static setLogCallback(logCallback: LogCallback): void;
|
|
33
|
-
/**
|
|
34
|
-
* Set custom logger function
|
|
35
|
-
*
|
|
36
|
-
* @param logCallback - callback taking a log object as param. If callback return falsy value then default logging
|
|
37
|
-
* will take place.
|
|
38
|
-
*/
|
|
39
|
-
setLogCallback(logCallback: LogCallback): void;
|
|
40
|
-
static setLogLevel(level: LogLevel): void;
|
|
41
|
-
start(): void;
|
|
42
|
-
stop(): void;
|
|
43
|
-
subscribe(): void;
|
|
44
|
-
unsubscribe(): void;
|
|
45
|
-
effectiveLevel({ level, message, tag }: Log): LogLevel;
|
|
46
|
-
onLog(log: Log): void;
|
|
47
|
-
}
|
|
48
|
-
export {};
|
|
49
|
-
//# sourceMappingURL=Logger.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../../../../src/modules/Logger.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;AAE1E,UAAU,GAAG;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,QAAQ,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;;GAMG;AACH,KAAK,WAAW,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC;AAEzC,qBAAa,MAAM;IACjB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAEtC,MAAM,CAAC,cAAc,IAAI,MAAM;IAO/B,OAAO,CAAC,aAAa,CAAqB;IAC1C,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,WAAW,CAAqB;IACxC,OAAO,CAAC,YAAY,CAA6B;;IASjD;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAIrD;;;;;OAKG;IACH,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAI9C,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAIzC,KAAK,IAAI,IAAI;IAOb,IAAI,IAAI,IAAI;IAOZ,SAAS,IAAI,IAAI;IAMjB,WAAW,IAAI,IAAI;IAOnB,cAAc,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,GAAG,GAAG,QAAQ;IAatD,KAAK,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI;CAatB"}
|
package/src/modules/Logger.ts
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type EmitterSubscription,
|
|
3
|
-
NativeEventEmitter,
|
|
4
|
-
NativeModules,
|
|
5
|
-
} from "react-native";
|
|
6
|
-
const MLRNLogging = NativeModules.MLRNLogging;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Supported log levels
|
|
10
|
-
*/
|
|
11
|
-
export type LogLevel = "error" | "warning" | "info" | "debug" | "verbose";
|
|
12
|
-
|
|
13
|
-
interface Log {
|
|
14
|
-
message: string;
|
|
15
|
-
level: LogLevel;
|
|
16
|
-
tag?: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* This callback is displayed as part of the Requester class.
|
|
21
|
-
* @param {object} log
|
|
22
|
-
* @param {string} log.message - the message of the log
|
|
23
|
-
* @param {string} log.level - log level
|
|
24
|
-
* @param {string} log.tag - optional tag used on android
|
|
25
|
-
*/
|
|
26
|
-
type LogCallback = (log: Log) => boolean;
|
|
27
|
-
|
|
28
|
-
export class Logger {
|
|
29
|
-
static instance: Logger | null = null;
|
|
30
|
-
|
|
31
|
-
static sharedInstance(): Logger {
|
|
32
|
-
if (this.instance === null) {
|
|
33
|
-
this.instance = new Logger();
|
|
34
|
-
}
|
|
35
|
-
return this.instance;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
private loggerEmitter: NativeEventEmitter;
|
|
39
|
-
private startedCount: number;
|
|
40
|
-
private logCallback: LogCallback | null;
|
|
41
|
-
private subscription: EmitterSubscription | null;
|
|
42
|
-
|
|
43
|
-
constructor() {
|
|
44
|
-
this.loggerEmitter = new NativeEventEmitter(MLRNLogging);
|
|
45
|
-
this.startedCount = 0;
|
|
46
|
-
this.logCallback = null;
|
|
47
|
-
this.subscription = null;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Set custom logger function
|
|
52
|
-
*
|
|
53
|
-
* @param logCallback - callback taking a log object as param. If callback return falsy value then default logging
|
|
54
|
-
* will take place.
|
|
55
|
-
*/
|
|
56
|
-
static setLogCallback(logCallback: LogCallback): void {
|
|
57
|
-
this.sharedInstance().setLogCallback(logCallback);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Set custom logger function
|
|
62
|
-
*
|
|
63
|
-
* @param logCallback - callback taking a log object as param. If callback return falsy value then default logging
|
|
64
|
-
* will take place.
|
|
65
|
-
*/
|
|
66
|
-
setLogCallback(logCallback: LogCallback): void {
|
|
67
|
-
this.logCallback = logCallback;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
static setLogLevel(level: LogLevel): void {
|
|
71
|
-
MLRNLogging.setLogLevel(level);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
start(): void {
|
|
75
|
-
if (this.startedCount === 0) {
|
|
76
|
-
this.subscribe();
|
|
77
|
-
}
|
|
78
|
-
this.startedCount += 1;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
stop(): void {
|
|
82
|
-
this.startedCount -= 1;
|
|
83
|
-
if (this.startedCount === 0) {
|
|
84
|
-
this.unsubscribe();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
subscribe(): void {
|
|
89
|
-
this.subscription = this.loggerEmitter.addListener("LogEvent", (log) => {
|
|
90
|
-
this.onLog(log);
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
unsubscribe(): void {
|
|
95
|
-
if (this.subscription) {
|
|
96
|
-
this.subscription.remove();
|
|
97
|
-
this.subscription = null;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
effectiveLevel({ level, message, tag }: Log): LogLevel {
|
|
102
|
-
if (level === "warning") {
|
|
103
|
-
if (
|
|
104
|
-
tag === "Mbgl-HttpRequest" &&
|
|
105
|
-
message.startsWith("Request failed due to a permanent error: Canceled")
|
|
106
|
-
) {
|
|
107
|
-
// this seems to happening too much to show a warning every time
|
|
108
|
-
return "info";
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
return level;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
onLog(log: Log): void {
|
|
115
|
-
if (!this.logCallback || !this.logCallback(log)) {
|
|
116
|
-
const { message } = log;
|
|
117
|
-
const level = this.effectiveLevel(log);
|
|
118
|
-
if (level === "error") {
|
|
119
|
-
console.error("MapLibre error", message, log);
|
|
120
|
-
} else if (level === "warning") {
|
|
121
|
-
console.warn("MapLibre warning", message, log);
|
|
122
|
-
} else {
|
|
123
|
-
console.log(`MapLibre [${level}]`, message, log);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|