nightingale-app-react-native 14.2.1 → 16.0.0
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/CHANGELOG.md +30 -0
- package/README.md +12 -12
- package/dist/definitions/index.d.ts +3 -4
- package/dist/definitions/index.d.ts.map +1 -1
- package/dist/index-browser.es.js +19 -24
- package/dist/index-browser.es.js.map +1 -1
- package/package.json +25 -32
- package/src/index.ts +19 -20
- package/dist/index-browsermodern.es.js +0 -55
- package/dist/index-browsermodern.es.js.map +0 -1
- package/src/.eslintrc.json +0 -27
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,36 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [16.0.0](https://github.com/christophehurpeau/nightingale/compare/v15.0.0...v16.0.0) (2025-03-30)
|
|
7
|
+
|
|
8
|
+
### ⚠ BREAKING CHANGES
|
|
9
|
+
|
|
10
|
+
* drop node 18
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* drop node 18 ([1b11a55](https://github.com/christophehurpeau/nightingale/commit/1b11a55dd24c9435be50519a748316079f554414))
|
|
15
|
+
|
|
16
|
+
Version bump for dependency: nightingale
|
|
17
|
+
Version bump for dependency: nightingale-react-native-console
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## [15.0.0](https://github.com/christophehurpeau/nightingale/compare/v14.2.1...v15.0.0) (2023-12-25)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### ⚠ BREAKING CHANGES
|
|
24
|
+
|
|
25
|
+
* update babel and drop browser modern version
|
|
26
|
+
|
|
27
|
+
### Features
|
|
28
|
+
|
|
29
|
+
* update babel and drop browser modern version ([5c76abc](https://github.com/christophehurpeau/nightingale/commit/5c76abc8bfb595a617fc4c8b795dae7e674ea664))
|
|
30
|
+
|
|
31
|
+
Version bump for dependency: nightingale
|
|
32
|
+
Version bump for dependency: nightingale-browser-console
|
|
33
|
+
Version bump for dependency: nightingale-react-native-console
|
|
34
|
+
|
|
35
|
+
|
|
6
36
|
## [14.2.1](https://github.com/christophehurpeau/nightingale/compare/v14.2.0...v14.2.1) (2023-11-05)
|
|
7
37
|
|
|
8
38
|
Note: no notable changes
|
package/README.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
<
|
|
1
|
+
<h1 align="center">
|
|
2
2
|
nightingale-app-react-native
|
|
3
|
-
</
|
|
3
|
+
</h1>
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
6
|
React Native and Expo logger for application
|
|
7
7
|
</p>
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
|
-
<a href="https://npmjs.org/package/nightingale-app-react-native"><img src="https://img.shields.io/npm/v/nightingale-app-react-native.svg?style=flat-square"></a>
|
|
11
|
-
<a href="https://npmjs.org/package/nightingale-app-react-native"><img src="https://img.shields.io/npm/dw/nightingale-app-react-native.svg?style=flat-square"></a>
|
|
12
|
-
<a href="https://npmjs.org/package/nightingale-app-react-native"><img src="https://img.shields.io/node/v/nightingale-app-react-native.svg?style=flat-square"></a>
|
|
13
|
-
<a href="https://npmjs.org/package/nightingale-app-react-native"><img src="https://img.shields.io/npm/types/nightingale-app-react-native.svg?style=flat-square"></a>
|
|
10
|
+
<a href="https://npmjs.org/package/nightingale-app-react-native"><img src="https://img.shields.io/npm/v/nightingale-app-react-native.svg?style=flat-square" alt="npm version"></a>
|
|
11
|
+
<a href="https://npmjs.org/package/nightingale-app-react-native"><img src="https://img.shields.io/npm/dw/nightingale-app-react-native.svg?style=flat-square" alt="npm downloads"></a>
|
|
12
|
+
<a href="https://npmjs.org/package/nightingale-app-react-native"><img src="https://img.shields.io/node/v/nightingale-app-react-native.svg?style=flat-square" alt="node version"></a>
|
|
13
|
+
<a href="https://npmjs.org/package/nightingale-app-react-native"><img src="https://img.shields.io/npm/types/nightingale-app-react-native.svg?style=flat-square" alt="types"></a>
|
|
14
14
|
</p>
|
|
15
15
|
|
|
16
16
|
## Install
|
|
@@ -22,16 +22,16 @@ npm install --save nightingale-app-react-native
|
|
|
22
22
|
## Usage
|
|
23
23
|
|
|
24
24
|
```js
|
|
25
|
-
import { appLogger } from
|
|
25
|
+
import { appLogger } from "nightingale-app-react-native";
|
|
26
26
|
|
|
27
|
-
appLogger.info(
|
|
27
|
+
appLogger.info("hello");
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
## Create children
|
|
31
31
|
|
|
32
32
|
```js
|
|
33
|
-
const myServiceLogger = appLogger.child(
|
|
34
|
-
myServiceLogger.debug(
|
|
33
|
+
const myServiceLogger = appLogger.child("services:myService");
|
|
34
|
+
myServiceLogger.debug("started");
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
### The Logger class
|
|
@@ -51,10 +51,10 @@ import {
|
|
|
51
51
|
configure,
|
|
52
52
|
ReactNativeConsoleHandler,
|
|
53
53
|
Level,
|
|
54
|
-
} from
|
|
54
|
+
} from "nightingale-app-react-native";
|
|
55
55
|
|
|
56
56
|
configure(
|
|
57
|
-
process.env.NODE_ENV ===
|
|
57
|
+
process.env.NODE_ENV === "production"
|
|
58
58
|
? []
|
|
59
59
|
: [
|
|
60
60
|
{
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Logger } from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export { configure, addConfig, Level } from 'nightingale';
|
|
1
|
+
import { BrowserConsoleHandler, Logger } from "nightingale";
|
|
2
|
+
import { ReactNativeConsoleHandler } from "nightingale-react-native-console";
|
|
3
|
+
export { configure, addConfig, Level } from "nightingale";
|
|
5
4
|
export declare const appLogger: Logger;
|
|
6
5
|
export declare const ReactNativeConsoleHandlerForPlatform: typeof BrowserConsoleHandler | typeof ReactNativeConsoleHandler;
|
|
7
6
|
export declare function listenReactNativeUnhandledErrors(logger?: Logger): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAS,MAAM,EAAa,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAG7E,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAE1D,eAAO,MAAM,SAAS,QAAoB,CAAC;AAE3C,eAAO,MAAM,oCAAoC,EAC7C,OAAO,qBAAqB,GAC5B,OAAO,yBACgE,CAAC;AAiB5E,wBAAgB,gCAAgC,CAC9C,MAAM,GAAE,MAGP,GACA,IAAI,CAkCN"}
|
package/dist/index-browser.es.js
CHANGED
|
@@ -1,56 +1,51 @@
|
|
|
1
|
-
import { Logger, configure, Level } from 'nightingale';
|
|
1
|
+
import { Logger, BrowserConsoleHandler, configure, Level } from 'nightingale';
|
|
2
2
|
export { Level, addConfig, configure } from 'nightingale';
|
|
3
|
-
import { BrowserConsoleHandler } from 'nightingale-browser-console';
|
|
4
3
|
import { ReactNativeConsoleHandler } from 'nightingale-react-native-console';
|
|
5
4
|
import { Platform } from 'react-native';
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
configure(process.env.NODE_ENV ===
|
|
6
|
+
const appLogger = new Logger("app");
|
|
7
|
+
const ReactNativeConsoleHandlerForPlatform = Platform.OS === "web" ? BrowserConsoleHandler : ReactNativeConsoleHandler;
|
|
8
|
+
configure(process.env.NODE_ENV === "production" ? [] : [{
|
|
10
9
|
pattern: /^app(:|$)/,
|
|
11
10
|
handlers: [new ReactNativeConsoleHandlerForPlatform(Level.DEBUG)],
|
|
12
11
|
stop: true
|
|
13
12
|
}, {
|
|
14
13
|
handlers: [new ReactNativeConsoleHandlerForPlatform(Level.INFO)]
|
|
15
14
|
}]);
|
|
16
|
-
function listenReactNativeUnhandledErrors(logger) {
|
|
17
|
-
var _global;
|
|
18
|
-
if (logger === void 0) {
|
|
19
|
-
logger = new Logger('nightingale:listenReactNativeUnhandledErrors', 'UnhandledErrors');
|
|
20
|
-
}
|
|
15
|
+
function listenReactNativeUnhandledErrors(logger = new Logger("nightingale:listenReactNativeUnhandledErrors", "UnhandledErrors")) {
|
|
21
16
|
// Check if Hermes is available and is being used for promises
|
|
22
17
|
// React Native v0.63 and v0.64 include global.HermesInternal but not 'hasPromise'
|
|
23
|
-
if (
|
|
24
|
-
|
|
18
|
+
if (globalThis.HermesInternal.hasPromise?.() && globalThis.HermesInternal.enablePromiseRejectionTracker) {
|
|
19
|
+
globalThis.HermesInternal.enablePromiseRejectionTracker({
|
|
25
20
|
allRejections: true,
|
|
26
|
-
onUnhandled:
|
|
21
|
+
onUnhandled: (id, rejection) => {
|
|
27
22
|
logger.error(rejection, {
|
|
28
23
|
unhandled: true,
|
|
29
|
-
type:
|
|
30
|
-
id
|
|
24
|
+
type: "promiseRejectionTracker",
|
|
25
|
+
id
|
|
31
26
|
});
|
|
32
27
|
}
|
|
33
28
|
});
|
|
34
29
|
} else {
|
|
35
|
-
throw new Error(
|
|
30
|
+
throw new Error("Only Hermes is supported.");
|
|
36
31
|
}
|
|
37
|
-
|
|
38
|
-
ErrorUtils.setGlobalHandler(
|
|
32
|
+
const globalHandler = ErrorUtils.getGlobalHandler();
|
|
33
|
+
ErrorUtils.setGlobalHandler((error, isFatal) => {
|
|
39
34
|
if (isFatal) {
|
|
40
35
|
logger.fatal(error, {
|
|
41
36
|
unhandled: true,
|
|
42
|
-
type:
|
|
43
|
-
isFatal
|
|
37
|
+
type: "globalHandler",
|
|
38
|
+
isFatal
|
|
44
39
|
});
|
|
45
40
|
} else {
|
|
46
41
|
logger.error(error, {
|
|
47
42
|
unhandled: true,
|
|
48
|
-
type:
|
|
49
|
-
isFatal
|
|
43
|
+
type: "globalHandler",
|
|
44
|
+
isFatal
|
|
50
45
|
});
|
|
51
46
|
}
|
|
52
|
-
if (
|
|
53
|
-
|
|
47
|
+
if (globalHandler) {
|
|
48
|
+
globalHandler(error, isFatal);
|
|
54
49
|
}
|
|
55
50
|
});
|
|
56
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-browser.es.js","sources":["../src/index.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"index-browser.es.js","sources":["../src/index.ts"],"sourcesContent":["import { BrowserConsoleHandler, Level, Logger, configure } from \"nightingale\";\nimport { ReactNativeConsoleHandler } from \"nightingale-react-native-console\";\nimport { Platform } from \"react-native\";\n\nexport { configure, addConfig, Level } from \"nightingale\";\n\nexport const appLogger = new Logger(\"app\");\n\nexport const ReactNativeConsoleHandlerForPlatform:\n | typeof BrowserConsoleHandler\n | typeof ReactNativeConsoleHandler =\n Platform.OS === \"web\" ? BrowserConsoleHandler : ReactNativeConsoleHandler;\n\nconfigure(\n process.env.NODE_ENV === \"production\"\n ? []\n : [\n {\n pattern: /^app(:|$)/,\n handlers: [new ReactNativeConsoleHandlerForPlatform(Level.DEBUG)],\n stop: true,\n },\n {\n handlers: [new ReactNativeConsoleHandlerForPlatform(Level.INFO)],\n },\n ],\n);\n\nexport function listenReactNativeUnhandledErrors(\n logger: Logger = new Logger(\n \"nightingale:listenReactNativeUnhandledErrors\",\n \"UnhandledErrors\",\n ),\n): void {\n // Check if Hermes is available and is being used for promises\n // React Native v0.63 and v0.64 include global.HermesInternal but not 'hasPromise'\n if (\n globalThis.HermesInternal.hasPromise?.() &&\n globalThis.HermesInternal.enablePromiseRejectionTracker\n ) {\n globalThis.HermesInternal.enablePromiseRejectionTracker({\n allRejections: true,\n onUnhandled: (id: number, rejection: Error) => {\n logger.error(rejection, {\n unhandled: true,\n type: \"promiseRejectionTracker\",\n id,\n });\n },\n });\n } else {\n throw new Error(\"Only Hermes is supported.\");\n }\n\n const globalHandler = ErrorUtils.getGlobalHandler();\n\n ErrorUtils.setGlobalHandler((error: Error, isFatal?: boolean) => {\n if (isFatal) {\n logger.fatal(error, { unhandled: true, type: \"globalHandler\", isFatal });\n } else {\n logger.error(error, { unhandled: true, type: \"globalHandler\", isFatal });\n }\n\n if (globalHandler) {\n globalHandler(error, isFatal);\n }\n });\n}\n"],"names":["appLogger","Logger","ReactNativeConsoleHandlerForPlatform","Platform","OS","BrowserConsoleHandler","ReactNativeConsoleHandler","configure","process","env","NODE_ENV","pattern","handlers","Level","DEBUG","stop","INFO","listenReactNativeUnhandledErrors","logger","globalThis","HermesInternal","hasPromise","enablePromiseRejectionTracker","allRejections","onUnhandled","id","rejection","error","unhandled","type","Error","globalHandler","ErrorUtils","getGlobalHandler","setGlobalHandler","isFatal","fatal"],"mappings":";;;;;MAMaA,SAAS,GAAG,IAAIC,MAAM,CAAC,KAAK;AAElC,MAAMC,oCAEuB,GAClCC,QAAQ,CAACC,EAAE,KAAK,KAAK,GAAGC,qBAAqB,GAAGC;AAElDC,SAAS,CACPC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GACjC,EAAE,GACF,CACE;AACEC,EAAAA,OAAO,EAAE,WAAW;EACpBC,QAAQ,EAAE,CAAC,IAAIV,oCAAoC,CAACW,KAAK,CAACC,KAAK,CAAC,CAAC;AACjEC,EAAAA,IAAI,EAAE;AACR,CAAC,EACD;EACEH,QAAQ,EAAE,CAAC,IAAIV,oCAAoC,CAACW,KAAK,CAACG,IAAI,CAAC;AACjE,CAAC,CAET,CAAC;AAEM,SAASC,gCAAgCA,CAC9CC,MAAc,GAAG,IAAIjB,MAAM,CACzB,8CAA8C,EAC9C,iBACF,CAAC,EACK;AACN;AACA;AACA,EAAA,IACEkB,UAAU,CAACC,cAAc,CAACC,UAAU,IAAI,IACxCF,UAAU,CAACC,cAAc,CAACE,6BAA6B,EACvD;AACAH,IAAAA,UAAU,CAACC,cAAc,CAACE,6BAA6B,CAAC;AACtDC,MAAAA,aAAa,EAAE,IAAI;AACnBC,MAAAA,WAAW,EAAEA,CAACC,EAAU,EAAEC,SAAgB,KAAK;AAC7CR,QAAAA,MAAM,CAACS,KAAK,CAACD,SAAS,EAAE;AACtBE,UAAAA,SAAS,EAAE,IAAI;AACfC,UAAAA,IAAI,EAAE,yBAAyB;AAC/BJ,UAAAA;AACF,SAAC,CAAC;AACJ;AACF,KAAC,CAAC;AACJ,GAAC,MAAM;AACL,IAAA,MAAM,IAAIK,KAAK,CAAC,2BAA2B,CAAC;AAC9C;AAEA,EAAA,MAAMC,aAAa,GAAGC,UAAU,CAACC,gBAAgB,EAAE;AAEnDD,EAAAA,UAAU,CAACE,gBAAgB,CAAC,CAACP,KAAY,EAAEQ,OAAiB,KAAK;AAC/D,IAAA,IAAIA,OAAO,EAAE;AACXjB,MAAAA,MAAM,CAACkB,KAAK,CAACT,KAAK,EAAE;AAAEC,QAAAA,SAAS,EAAE,IAAI;AAAEC,QAAAA,IAAI,EAAE,eAAe;AAAEM,QAAAA;AAAQ,OAAC,CAAC;AAC1E,KAAC,MAAM;AACLjB,MAAAA,MAAM,CAACS,KAAK,CAACA,KAAK,EAAE;AAAEC,QAAAA,SAAS,EAAE,IAAI;AAAEC,QAAAA,IAAI,EAAE,eAAe;AAAEM,QAAAA;AAAQ,OAAC,CAAC;AAC1E;AAEA,IAAA,IAAIJ,aAAa,EAAE;AACjBA,MAAAA,aAAa,CAACJ,KAAK,EAAEQ,OAAO,CAAC;AAC/B;AACF,GAAC,CAAC;AACJ;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nightingale-app-react-native",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "16.0.0",
|
|
4
4
|
"description": "React Native and Expo logger for application",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nightingale",
|
|
@@ -18,17 +18,9 @@
|
|
|
18
18
|
"homepage": "https://github.com/christophehurpeau/nightingale",
|
|
19
19
|
"type": "module",
|
|
20
20
|
"engines": {
|
|
21
|
-
"node": ">=
|
|
22
|
-
},
|
|
23
|
-
"browserslist": {
|
|
24
|
-
"production": [
|
|
25
|
-
"defaults",
|
|
26
|
-
"> 0.2%",
|
|
27
|
-
"not ie < 12",
|
|
28
|
-
"not safari < 10",
|
|
29
|
-
"not ios_saf < 10"
|
|
30
|
-
]
|
|
21
|
+
"node": ">=22.14.0"
|
|
31
22
|
},
|
|
23
|
+
"sideEffects": false,
|
|
32
24
|
"types": "./dist/definitions/index.d.ts",
|
|
33
25
|
"module": "./dist/index-browser.es.js",
|
|
34
26
|
"browser": "./dist/index-browser.es.js",
|
|
@@ -37,14 +29,10 @@
|
|
|
37
29
|
".": {
|
|
38
30
|
"types": "./dist/definitions/index.d.ts",
|
|
39
31
|
"browser": {
|
|
40
|
-
"browser:modern": {
|
|
41
|
-
"import": "./dist/index-browsermodern.es.js"
|
|
42
|
-
},
|
|
43
32
|
"import": "./dist/index-browser.es.js"
|
|
44
33
|
}
|
|
45
34
|
}
|
|
46
35
|
},
|
|
47
|
-
"sideEffects": false,
|
|
48
36
|
"files": [
|
|
49
37
|
"src",
|
|
50
38
|
"dist"
|
|
@@ -55,24 +43,30 @@
|
|
|
55
43
|
"clean": "yarn clean:build",
|
|
56
44
|
"clean:build": "pob-babel-clean-out dist",
|
|
57
45
|
"lint": "yarn run lint:eslint",
|
|
58
|
-
"lint:eslint": "yarn ../.. run eslint --
|
|
46
|
+
"lint:eslint": "yarn ../.. run eslint --quiet packages/nightingale-app-react-native",
|
|
59
47
|
"watch": "yarn clean:build && rollup --config rollup.config.mjs --watch"
|
|
60
48
|
},
|
|
61
|
-
"
|
|
49
|
+
"browserslist": {
|
|
50
|
+
"production": [
|
|
51
|
+
"defaults",
|
|
52
|
+
"> 0.2%",
|
|
53
|
+
"not ie < 12",
|
|
54
|
+
"not safari < 10",
|
|
55
|
+
"not ios_saf < 10"
|
|
56
|
+
]
|
|
57
|
+
},
|
|
62
58
|
"pob": {
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
59
|
+
"bundler": "rollup-babel",
|
|
60
|
+
"entries": [
|
|
61
|
+
"index"
|
|
62
|
+
],
|
|
63
|
+
"envs": [
|
|
68
64
|
{
|
|
69
65
|
"target": "browser"
|
|
70
66
|
}
|
|
71
|
-
],
|
|
72
|
-
"entries": [
|
|
73
|
-
"index"
|
|
74
67
|
]
|
|
75
68
|
},
|
|
69
|
+
"prettier": "@pob/root/prettier-config",
|
|
76
70
|
"peerDependencies": {
|
|
77
71
|
"react-native": "*",
|
|
78
72
|
"react-native-web": "*"
|
|
@@ -83,14 +77,13 @@
|
|
|
83
77
|
}
|
|
84
78
|
},
|
|
85
79
|
"dependencies": {
|
|
86
|
-
"nightingale": "
|
|
87
|
-
"nightingale-
|
|
88
|
-
"nightingale-react-native-console": "14.2.1"
|
|
80
|
+
"nightingale": "16.0.0",
|
|
81
|
+
"nightingale-react-native-console": "16.0.0"
|
|
89
82
|
},
|
|
90
83
|
"devDependencies": {
|
|
91
|
-
"@babel/core": "7.
|
|
92
|
-
"@babel/preset-env": "7.
|
|
93
|
-
"pob-babel": "
|
|
94
|
-
"typescript": "5.
|
|
84
|
+
"@babel/core": "7.26.10",
|
|
85
|
+
"@babel/preset-env": "7.26.9",
|
|
86
|
+
"pob-babel": "43.4.0",
|
|
87
|
+
"typescript": "5.8.2"
|
|
95
88
|
}
|
|
96
89
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import { Logger, configure
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Platform } from 'react-native';
|
|
1
|
+
import { BrowserConsoleHandler, Level, Logger, configure } from "nightingale";
|
|
2
|
+
import { ReactNativeConsoleHandler } from "nightingale-react-native-console";
|
|
3
|
+
import { Platform } from "react-native";
|
|
5
4
|
|
|
6
|
-
export { configure, addConfig, Level } from
|
|
5
|
+
export { configure, addConfig, Level } from "nightingale";
|
|
7
6
|
|
|
8
|
-
export const appLogger = new Logger(
|
|
7
|
+
export const appLogger = new Logger("app");
|
|
9
8
|
|
|
10
9
|
export const ReactNativeConsoleHandlerForPlatform:
|
|
11
10
|
| typeof BrowserConsoleHandler
|
|
12
11
|
| typeof ReactNativeConsoleHandler =
|
|
13
|
-
Platform.OS ===
|
|
12
|
+
Platform.OS === "web" ? BrowserConsoleHandler : ReactNativeConsoleHandler;
|
|
14
13
|
|
|
15
14
|
configure(
|
|
16
|
-
process.env.NODE_ENV ===
|
|
15
|
+
process.env.NODE_ENV === "production"
|
|
17
16
|
? []
|
|
18
17
|
: [
|
|
19
18
|
{
|
|
@@ -29,41 +28,41 @@ configure(
|
|
|
29
28
|
|
|
30
29
|
export function listenReactNativeUnhandledErrors(
|
|
31
30
|
logger: Logger = new Logger(
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
"nightingale:listenReactNativeUnhandledErrors",
|
|
32
|
+
"UnhandledErrors",
|
|
34
33
|
),
|
|
35
34
|
): void {
|
|
36
35
|
// Check if Hermes is available and is being used for promises
|
|
37
36
|
// React Native v0.63 and v0.64 include global.HermesInternal but not 'hasPromise'
|
|
38
37
|
if (
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
globalThis.HermesInternal.hasPromise?.() &&
|
|
39
|
+
globalThis.HermesInternal.enablePromiseRejectionTracker
|
|
41
40
|
) {
|
|
42
|
-
|
|
41
|
+
globalThis.HermesInternal.enablePromiseRejectionTracker({
|
|
43
42
|
allRejections: true,
|
|
44
43
|
onUnhandled: (id: number, rejection: Error) => {
|
|
45
44
|
logger.error(rejection, {
|
|
46
45
|
unhandled: true,
|
|
47
|
-
type:
|
|
46
|
+
type: "promiseRejectionTracker",
|
|
48
47
|
id,
|
|
49
48
|
});
|
|
50
49
|
},
|
|
51
50
|
});
|
|
52
51
|
} else {
|
|
53
|
-
throw new Error(
|
|
52
|
+
throw new Error("Only Hermes is supported.");
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
const
|
|
55
|
+
const globalHandler = ErrorUtils.getGlobalHandler();
|
|
57
56
|
|
|
58
57
|
ErrorUtils.setGlobalHandler((error: Error, isFatal?: boolean) => {
|
|
59
58
|
if (isFatal) {
|
|
60
|
-
logger.fatal(error, { unhandled: true, type:
|
|
59
|
+
logger.fatal(error, { unhandled: true, type: "globalHandler", isFatal });
|
|
61
60
|
} else {
|
|
62
|
-
logger.error(error, { unhandled: true, type:
|
|
61
|
+
logger.error(error, { unhandled: true, type: "globalHandler", isFatal });
|
|
63
62
|
}
|
|
64
63
|
|
|
65
|
-
if (
|
|
66
|
-
|
|
64
|
+
if (globalHandler) {
|
|
65
|
+
globalHandler(error, isFatal);
|
|
67
66
|
}
|
|
68
67
|
});
|
|
69
68
|
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { Logger, configure, Level } from 'nightingale';
|
|
2
|
-
export { Level, addConfig, configure } from 'nightingale';
|
|
3
|
-
import { BrowserConsoleHandler } from 'nightingale-browser-console';
|
|
4
|
-
import { ReactNativeConsoleHandler } from 'nightingale-react-native-console';
|
|
5
|
-
import { Platform } from 'react-native';
|
|
6
|
-
|
|
7
|
-
const appLogger = new Logger('app');
|
|
8
|
-
const ReactNativeConsoleHandlerForPlatform = Platform.OS === 'web' ? BrowserConsoleHandler : ReactNativeConsoleHandler;
|
|
9
|
-
configure(process.env.NODE_ENV === 'production' ? [] : [{
|
|
10
|
-
pattern: /^app(:|$)/,
|
|
11
|
-
handlers: [new ReactNativeConsoleHandlerForPlatform(Level.DEBUG)],
|
|
12
|
-
stop: true
|
|
13
|
-
}, {
|
|
14
|
-
handlers: [new ReactNativeConsoleHandlerForPlatform(Level.INFO)]
|
|
15
|
-
}]);
|
|
16
|
-
function listenReactNativeUnhandledErrors(logger = new Logger('nightingale:listenReactNativeUnhandledErrors', 'UnhandledErrors')) {
|
|
17
|
-
// Check if Hermes is available and is being used for promises
|
|
18
|
-
// React Native v0.63 and v0.64 include global.HermesInternal but not 'hasPromise'
|
|
19
|
-
if (global?.HermesInternal?.hasPromise?.() && global.HermesInternal.enablePromiseRejectionTracker) {
|
|
20
|
-
global.HermesInternal.enablePromiseRejectionTracker({
|
|
21
|
-
allRejections: true,
|
|
22
|
-
onUnhandled: (id, rejection) => {
|
|
23
|
-
logger.error(rejection, {
|
|
24
|
-
unhandled: true,
|
|
25
|
-
type: 'promiseRejectionTracker',
|
|
26
|
-
id
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
} else {
|
|
31
|
-
throw new Error('Only Hermes is supported.');
|
|
32
|
-
}
|
|
33
|
-
const globalHander = ErrorUtils.getGlobalHandler();
|
|
34
|
-
ErrorUtils.setGlobalHandler((error, isFatal) => {
|
|
35
|
-
if (isFatal) {
|
|
36
|
-
logger.fatal(error, {
|
|
37
|
-
unhandled: true,
|
|
38
|
-
type: 'globalHandler',
|
|
39
|
-
isFatal
|
|
40
|
-
});
|
|
41
|
-
} else {
|
|
42
|
-
logger.error(error, {
|
|
43
|
-
unhandled: true,
|
|
44
|
-
type: 'globalHandler',
|
|
45
|
-
isFatal
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
if (globalHander) {
|
|
49
|
-
globalHander(error, isFatal);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export { ReactNativeConsoleHandlerForPlatform, appLogger, listenReactNativeUnhandledErrors };
|
|
55
|
-
//# sourceMappingURL=index-browsermodern.es.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-browsermodern.es.js","sources":["../src/index.ts"],"sourcesContent":["import { Logger, configure, Level } from 'nightingale';\nimport { BrowserConsoleHandler } from 'nightingale-browser-console';\nimport { ReactNativeConsoleHandler } from 'nightingale-react-native-console';\nimport { Platform } from 'react-native';\n\nexport { configure, addConfig, Level } from 'nightingale';\n\nexport const appLogger = new Logger('app');\n\nexport const ReactNativeConsoleHandlerForPlatform:\n | typeof BrowserConsoleHandler\n | typeof ReactNativeConsoleHandler =\n Platform.OS === 'web' ? BrowserConsoleHandler : ReactNativeConsoleHandler;\n\nconfigure(\n process.env.NODE_ENV === 'production'\n ? []\n : [\n {\n pattern: /^app(:|$)/,\n handlers: [new ReactNativeConsoleHandlerForPlatform(Level.DEBUG)],\n stop: true,\n },\n {\n handlers: [new ReactNativeConsoleHandlerForPlatform(Level.INFO)],\n },\n ],\n);\n\nexport function listenReactNativeUnhandledErrors(\n logger: Logger = new Logger(\n 'nightingale:listenReactNativeUnhandledErrors',\n 'UnhandledErrors',\n ),\n): void {\n // Check if Hermes is available and is being used for promises\n // React Native v0.63 and v0.64 include global.HermesInternal but not 'hasPromise'\n if (\n global?.HermesInternal?.hasPromise?.() &&\n global.HermesInternal.enablePromiseRejectionTracker\n ) {\n global.HermesInternal.enablePromiseRejectionTracker({\n allRejections: true,\n onUnhandled: (id: number, rejection: Error) => {\n logger.error(rejection, {\n unhandled: true,\n type: 'promiseRejectionTracker',\n id,\n });\n },\n });\n } else {\n throw new Error('Only Hermes is supported.');\n }\n\n const globalHander = ErrorUtils.getGlobalHandler();\n\n ErrorUtils.setGlobalHandler((error: Error, isFatal?: boolean) => {\n if (isFatal) {\n logger.fatal(error, { unhandled: true, type: 'globalHandler', isFatal });\n } else {\n logger.error(error, { unhandled: true, type: 'globalHandler', isFatal });\n }\n\n if (globalHander) {\n globalHander(error, isFatal);\n }\n });\n}\n"],"names":["appLogger","Logger","ReactNativeConsoleHandlerForPlatform","Platform","OS","BrowserConsoleHandler","ReactNativeConsoleHandler","configure","process","env","NODE_ENV","pattern","handlers","Level","DEBUG","stop","INFO","listenReactNativeUnhandledErrors","logger","global","HermesInternal","hasPromise","enablePromiseRejectionTracker","allRejections","onUnhandled","id","rejection","error","unhandled","type","Error","globalHander","ErrorUtils","getGlobalHandler","setGlobalHandler","isFatal","fatal"],"mappings":";;;;;;MAOaA,SAAS,GAAG,IAAIC,MAAM,CAAC,KAAK,EAAC;AAEnC,MAAMC,oCAEuB,GAClCC,QAAQ,CAACC,EAAE,KAAK,KAAK,GAAGC,qBAAqB,GAAGC,0BAAyB;AAE3EC,SAAS,CACPC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GACjC,EAAE,GACF,CACE;AACEC,EAAAA,OAAO,EAAE,WAAW;EACpBC,QAAQ,EAAE,CAAC,IAAIV,oCAAoC,CAACW,KAAK,CAACC,KAAK,CAAC,CAAC;AACjEC,EAAAA,IAAI,EAAE,IAAA;AACR,CAAC,EACD;EACEH,QAAQ,EAAE,CAAC,IAAIV,oCAAoC,CAACW,KAAK,CAACG,IAAI,CAAC,CAAA;AACjE,CAAC,CAET,CAAC,CAAA;AAEM,SAASC,gCAAgCA,CAC9CC,MAAc,GAAG,IAAIjB,MAAM,CACzB,8CAA8C,EAC9C,iBACF,CAAC,EACK;AACN;AACA;AACA,EAAA,IACEkB,MAAM,EAAEC,cAAc,EAAEC,UAAU,IAAI,IACtCF,MAAM,CAACC,cAAc,CAACE,6BAA6B,EACnD;AACAH,IAAAA,MAAM,CAACC,cAAc,CAACE,6BAA6B,CAAC;AAClDC,MAAAA,aAAa,EAAE,IAAI;AACnBC,MAAAA,WAAW,EAAEA,CAACC,EAAU,EAAEC,SAAgB,KAAK;AAC7CR,QAAAA,MAAM,CAACS,KAAK,CAACD,SAAS,EAAE;AACtBE,UAAAA,SAAS,EAAE,IAAI;AACfC,UAAAA,IAAI,EAAE,yBAAyB;AAC/BJ,UAAAA,EAAAA;AACF,SAAC,CAAC,CAAA;AACJ,OAAA;AACF,KAAC,CAAC,CAAA;AACJ,GAAC,MAAM;AACL,IAAA,MAAM,IAAIK,KAAK,CAAC,2BAA2B,CAAC,CAAA;AAC9C,GAAA;AAEA,EAAA,MAAMC,YAAY,GAAGC,UAAU,CAACC,gBAAgB,EAAE,CAAA;AAElDD,EAAAA,UAAU,CAACE,gBAAgB,CAAC,CAACP,KAAY,EAAEQ,OAAiB,KAAK;AAC/D,IAAA,IAAIA,OAAO,EAAE;AACXjB,MAAAA,MAAM,CAACkB,KAAK,CAACT,KAAK,EAAE;AAAEC,QAAAA,SAAS,EAAE,IAAI;AAAEC,QAAAA,IAAI,EAAE,eAAe;AAAEM,QAAAA,OAAAA;AAAQ,OAAC,CAAC,CAAA;AAC1E,KAAC,MAAM;AACLjB,MAAAA,MAAM,CAACS,KAAK,CAACA,KAAK,EAAE;AAAEC,QAAAA,SAAS,EAAE,IAAI;AAAEC,QAAAA,IAAI,EAAE,eAAe;AAAEM,QAAAA,OAAAA;AAAQ,OAAC,CAAC,CAAA;AAC1E,KAAA;AAEA,IAAA,IAAIJ,YAAY,EAAE;AAChBA,MAAAA,YAAY,CAACJ,KAAK,EAAEQ,OAAO,CAAC,CAAA;AAC9B,KAAA;AACF,GAAC,CAAC,CAAA;AACJ;;;;"}
|
package/src/.eslintrc.json
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"root": true,
|
|
3
|
-
"parser": "@typescript-eslint/parser",
|
|
4
|
-
"parserOptions": {
|
|
5
|
-
"project": "packages/nightingale-app-react-native/tsconfig.json"
|
|
6
|
-
},
|
|
7
|
-
"plugins": ["@typescript-eslint"],
|
|
8
|
-
"extends": ["@pob/eslint-config-typescript"],
|
|
9
|
-
"ignorePatterns": ["*.d.ts"],
|
|
10
|
-
"overrides": [
|
|
11
|
-
{
|
|
12
|
-
"files": ["**/*.test.ts", "__tests__/**/*.ts"],
|
|
13
|
-
"extends": ["@pob/eslint-config-typescript/test"],
|
|
14
|
-
"env": {
|
|
15
|
-
"jest": true
|
|
16
|
-
},
|
|
17
|
-
"rules": {
|
|
18
|
-
"import/no-extraneous-dependencies": [
|
|
19
|
-
"error",
|
|
20
|
-
{
|
|
21
|
-
"devDependencies": true
|
|
22
|
-
}
|
|
23
|
-
]
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
}
|