@rife/logger 0.0.6-beta.18 → 0.0.6-beta.20
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/dist/cjs/pino/index.cjs +3 -6
- package/dist/cjs/pino/worker/pino-file.cjs +127 -91
- package/dist/cjs/pino/worker/pino-pretty.cjs +497 -265
- package/dist/cjs/pino/worker/pino-rotate.cjs +7 -5
- package/dist/cjs/pino/worker/pino-worker.cjs +133 -97
- package/dist/cjs/pino/worker/thread-stream.cjs +6 -6
- package/dist/esm/pino/index.mjs +6 -14
- package/dist/esm/pino/rotate.mjs +3 -8
- package/dist/esm/pino/worker/pino-file.cjs +127 -91
- package/dist/esm/pino/worker/pino-pretty.cjs +497 -265
- package/dist/esm/pino/worker/pino-rotate.cjs +7 -5
- package/dist/esm/pino/worker/pino-worker.cjs +133 -97
- package/dist/esm/pino/worker/thread-stream.cjs +6 -6
- package/dist/esm/test.mjs +1 -1
- package/dist/worker/pino-file.cjs +127 -91
- package/dist/worker/pino-pretty.cjs +497 -265
- package/dist/worker/pino-rotate.cjs +7 -5
- package/dist/worker/pino-worker.cjs +133 -97
- package/dist/worker/thread-stream.cjs +6 -6
- package/package.json +6 -6
- package/src/pino/index.ts +6 -16
- package/src/trace.ts +1 -1
- package/tsconfig.json +2 -1
- package/dist/esm/rslib-runtime.mjs +0 -19
|
@@ -26,12 +26,12 @@ var __webpack_modules__ = {
|
|
|
26
26
|
"use strict";
|
|
27
27
|
const WAIT_MS = 10000;
|
|
28
28
|
function wait(state, index, expected, timeout, done) {
|
|
29
|
-
const max =
|
|
29
|
+
const max = 1 / 0 === timeout ? 1 / 0 : Date.now() + timeout;
|
|
30
30
|
const check = ()=>{
|
|
31
31
|
const current = Atomics.load(state, index);
|
|
32
32
|
if (current === expected) return void done(null, 'ok');
|
|
33
|
-
if (
|
|
34
|
-
const remaining =
|
|
33
|
+
if (1 / 0 !== max && Date.now() > max) return void done(null, 'timed-out');
|
|
34
|
+
const remaining = 1 / 0 === max ? WAIT_MS : Math.min(WAIT_MS, Math.max(1, max - Date.now()));
|
|
35
35
|
const result = Atomics.waitAsync(state, index, current, remaining);
|
|
36
36
|
if (result.async) result.value.then(check);
|
|
37
37
|
else setImmediate(check);
|
|
@@ -39,12 +39,12 @@ var __webpack_modules__ = {
|
|
|
39
39
|
check();
|
|
40
40
|
}
|
|
41
41
|
function waitDiff(state, index, expected, timeout, done) {
|
|
42
|
-
const max =
|
|
42
|
+
const max = 1 / 0 === timeout ? 1 / 0 : Date.now() + timeout;
|
|
43
43
|
const check = ()=>{
|
|
44
44
|
const current = Atomics.load(state, index);
|
|
45
45
|
if (current !== expected) return void done(null, 'ok');
|
|
46
|
-
if (
|
|
47
|
-
const remaining =
|
|
46
|
+
if (1 / 0 !== max && Date.now() > max) return void done(null, 'timed-out');
|
|
47
|
+
const remaining = 1 / 0 === max ? WAIT_MS : Math.min(WAIT_MS, Math.max(1, max - Date.now()));
|
|
48
48
|
const result = Atomics.waitAsync(state, index, expected, remaining);
|
|
49
49
|
if (result.async) result.value.then((res)=>{
|
|
50
50
|
if ('ok' === res) return void done(null, 'ok');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rife/logger",
|
|
3
|
-
"version": "0.0.6-beta.
|
|
3
|
+
"version": "0.0.6-beta.20",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -37,15 +37,15 @@
|
|
|
37
37
|
"tsconfig.json"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"pino": "^10.
|
|
41
|
-
"pino-pretty": "^13.
|
|
40
|
+
"pino": "^10.4.0",
|
|
41
|
+
"pino-pretty": "^13.2.0",
|
|
42
42
|
"pino-std-serializers": "^7.1.0",
|
|
43
43
|
"rotating-file-stream": "^3.2.9"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"
|
|
47
|
-
"@rife/plugin-rstack": "0.0.1-beta.
|
|
48
|
-
"
|
|
46
|
+
"@rife/cli": "0.0.6-beta.28",
|
|
47
|
+
"@rife/plugin-rstack": "0.0.1-beta.27",
|
|
48
|
+
"thread-stream": "^4.0.0"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"dev": "rife dev",
|
package/src/pino/index.ts
CHANGED
|
@@ -5,11 +5,12 @@ export { pino };
|
|
|
5
5
|
|
|
6
6
|
import { genTraceId, getTraceId, runInTrace } from '../trace';
|
|
7
7
|
|
|
8
|
-
declare
|
|
9
|
-
|
|
8
|
+
declare let RSTACK_NODE_SINGLE_FILE_BUNDLE: any;
|
|
9
|
+
|
|
10
|
+
export type Logger = pino.Logger;
|
|
10
11
|
|
|
11
12
|
// https://github.com/pinojs/pino/blob/master/docs/api.md
|
|
12
|
-
function
|
|
13
|
+
export function createLogger() {
|
|
13
14
|
const targets: any = [];
|
|
14
15
|
|
|
15
16
|
const rotate = `./rotate${path.extname(__filename)}`;
|
|
@@ -20,12 +21,7 @@ function getPinoConfig() {
|
|
|
20
21
|
options: { path: './logs/' },
|
|
21
22
|
});
|
|
22
23
|
|
|
23
|
-
if (
|
|
24
|
-
typeof __isNodeSingleFileBundle !== 'undefined' ||
|
|
25
|
-
typeof __isVite !== 'undefined' || // remix
|
|
26
|
-
(global as any)?.__remix_devServerHooks || // remix
|
|
27
|
-
process.env.NODE_ENV !== 'development'
|
|
28
|
-
) {
|
|
24
|
+
if (typeof (RSTACK_NODE_SINGLE_FILE_BUNDLE as any) !== 'undefined' || process.env.NODE_ENV !== 'development') {
|
|
29
25
|
// 打包单文件的时候自动拷贝worker
|
|
30
26
|
(globalThis as any).__bundlerPathsOverrides = {
|
|
31
27
|
'pino-pretty': path.join(__dirname, './worker/pino-pretty.cjs'),
|
|
@@ -103,12 +99,6 @@ function getPinoConfig() {
|
|
|
103
99
|
},
|
|
104
100
|
};
|
|
105
101
|
|
|
106
|
-
return config;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export type Logger = pino.Logger<never, boolean>;
|
|
110
|
-
|
|
111
|
-
export function createLogger() {
|
|
112
102
|
const logger: Logger = pino({
|
|
113
103
|
// https://github.com/pinojs/pino/blob/main/docs/api.md#opt-serializers
|
|
114
104
|
base: { pid: process.pid },
|
|
@@ -116,7 +106,7 @@ export function createLogger() {
|
|
|
116
106
|
errorKey: 'error',
|
|
117
107
|
timestamp: pino.stdTimeFunctions.epochTime,
|
|
118
108
|
// timestamp: process.env.NODE_ENV === 'production' ? pino.stdTimeFunctions.epochTime : pino.stdTimeFunctions.isoTime,
|
|
119
|
-
...
|
|
109
|
+
...config,
|
|
120
110
|
});
|
|
121
111
|
|
|
122
112
|
return { logger };
|
package/src/trace.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'async_hooks';
|
|
2
2
|
|
|
3
|
-
const als = new AsyncLocalStorage<{ traceId: string } & any
|
|
3
|
+
const als = new AsyncLocalStorage<{ traceId: string } & Record<string, any>>();
|
|
4
4
|
|
|
5
5
|
export function runInTrace<T>(data: any, fn: (...args: any[]) => T): T {
|
|
6
6
|
return als.run(data, fn);
|
package/tsconfig.json
CHANGED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
var __webpack_modules__ = {};
|
|
3
|
-
var __webpack_module_cache__ = {};
|
|
4
|
-
function __webpack_require__(moduleId) {
|
|
5
|
-
var cachedModule = __webpack_module_cache__[moduleId];
|
|
6
|
-
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
7
|
-
var module = __webpack_module_cache__[moduleId] = {
|
|
8
|
-
exports: {}
|
|
9
|
-
};
|
|
10
|
-
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
11
|
-
return module.exports;
|
|
12
|
-
}
|
|
13
|
-
__webpack_require__.m = __webpack_modules__;
|
|
14
|
-
(()=>{
|
|
15
|
-
__webpack_require__.add = function(modules) {
|
|
16
|
-
Object.assign(__webpack_require__.m, modules);
|
|
17
|
-
};
|
|
18
|
-
})();
|
|
19
|
-
export { __webpack_require__ };
|