@effectstream/log 0.100.20 → 0.100.22
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/package.json +2 -2
- package/src/mod.ts +0 -1
- package/src/process-handlers.ts +0 -38
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effectstream/log",
|
|
3
|
-
"version": "0.100.
|
|
3
|
+
"version": "0.100.22",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://effectstream.github.io/docs/",
|
|
6
6
|
"repository": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"exports": "./src/mod.ts",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@effectstream/utils": "0.100.
|
|
16
|
+
"@effectstream/utils": "0.100.22",
|
|
17
17
|
"@opentelemetry/api": "^1.9.0",
|
|
18
18
|
"@opentelemetry/api-logs": "0.56.0",
|
|
19
19
|
"@opentelemetry/exporter-logs-otlp-http": "0.56.0",
|
package/src/mod.ts
CHANGED
|
@@ -11,7 +11,6 @@ export {
|
|
|
11
11
|
} from "./const.ts";
|
|
12
12
|
export { attachTransport } from "./tslog.ts";
|
|
13
13
|
export { DefaultLogLevels } from "./tslog.ts";
|
|
14
|
-
export { installUnhandledRejectionLogger } from "./process-handlers.ts";
|
|
15
14
|
|
|
16
15
|
// re-exporting this
|
|
17
16
|
// so that we don't need to re-import opentelemetry in every component
|
package/src/process-handlers.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { SeverityNumber } from "@opentelemetry/api-logs";
|
|
2
|
-
import { log } from "./mod.ts";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Install a process-wide `unhandledRejection` handler.
|
|
6
|
-
*
|
|
7
|
-
* By default the handler logs the error at ERROR and re-crashes the process
|
|
8
|
-
* via `process.exit(1)` — preserving the "let it crash" semantic that Node /
|
|
9
|
-
* Bun apply when no handler is registered. The point of installing this
|
|
10
|
-
* handler is *visibility*: without it, Bun crashes silently with no log line
|
|
11
|
-
* about what the rejection actually was.
|
|
12
|
-
*
|
|
13
|
-
* Pass `shouldSurvive` to opt specific errors out of the crash — useful for
|
|
14
|
-
* known-transient failures from external systems (e.g. a pg pool ECONNRESET
|
|
15
|
-
* from a serverless Postgres cold-start). Surviving errors are logged at
|
|
16
|
-
* WARN; non-surviving ones at ERROR before exit.
|
|
17
|
-
*
|
|
18
|
-
* Idempotent: only the first call in this module registers a listener.
|
|
19
|
-
*/
|
|
20
|
-
let unhandledRejectionLoggerInstalled = false;
|
|
21
|
-
|
|
22
|
-
export function installUnhandledRejectionLogger(
|
|
23
|
-
componentName: string,
|
|
24
|
-
shouldSurvive?: (reason: unknown) => boolean,
|
|
25
|
-
): void {
|
|
26
|
-
if (unhandledRejectionLoggerInstalled) return;
|
|
27
|
-
unhandledRejectionLoggerInstalled = true;
|
|
28
|
-
process.on("unhandledRejection", (reason: unknown) => {
|
|
29
|
-
const survive = shouldSurvive?.(reason) ?? false;
|
|
30
|
-
log.remote(
|
|
31
|
-
componentName,
|
|
32
|
-
["unhandledRejection"],
|
|
33
|
-
survive ? SeverityNumber.WARN : SeverityNumber.ERROR,
|
|
34
|
-
(log) => log(reason),
|
|
35
|
-
);
|
|
36
|
-
if (!survive) process.exit(1);
|
|
37
|
-
});
|
|
38
|
-
}
|