@rife/logger 0.0.6-beta.15 → 0.0.6-beta.17
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/common.cjs +9 -5
- package/dist/cjs/env.cjs +13 -9
- package/dist/cjs/index.cjs +9 -5
- package/dist/cjs/pino/index.cjs +34 -13
- package/dist/cjs/pino/rotate.cjs +12 -8
- package/dist/cjs/pino/worker/pino-file.cjs +198 -106
- package/dist/cjs/pino/worker/pino-pretty.cjs +47 -43
- package/dist/cjs/pino/worker/pino-rotate.cjs +12 -8
- package/dist/cjs/pino/worker/pino-worker.cjs +198 -106
- package/dist/cjs/pino/worker/thread-stream.cjs +107 -13
- package/dist/cjs/trace.cjs +11 -7
- package/dist/esm/common.mjs +2 -2
- package/dist/esm/pino/index.mjs +33 -16
- package/dist/esm/pino/rotate.mjs +2 -2
- package/dist/esm/pino/worker/pino-file.cjs +198 -106
- package/dist/esm/pino/worker/pino-pretty.cjs +47 -43
- package/dist/esm/pino/worker/pino-rotate.cjs +12 -8
- package/dist/esm/pino/worker/pino-worker.cjs +198 -106
- package/dist/esm/pino/worker/thread-stream.cjs +107 -13
- package/dist/worker/pino-file.cjs +198 -106
- package/dist/worker/pino-pretty.cjs +47 -43
- package/dist/worker/pino-rotate.cjs +12 -8
- package/dist/worker/pino-worker.cjs +198 -106
- package/dist/worker/thread-stream.cjs +107 -13
- package/package.json +3 -3
- package/src/pino/index.ts +16 -6
- package/dist/cjs/worker/index.cjs +0 -5
- package/dist/esm/worker/index.mjs +0 -1
- package/src/worker/index.ts +0 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_modules__ = {
|
|
3
|
-
"../../node_modules/.pnpm/real-require@0.
|
|
3
|
+
"../../node_modules/.pnpm/real-require@1.0.0/node_modules/real-require/src/index.js" (module1) {
|
|
4
4
|
const realImport = new Function('modulePath', 'return import(modulePath)');
|
|
5
5
|
function realRequire(modulePath) {
|
|
6
6
|
if ('function' == typeof __non_webpack__require__) return __non_webpack__require__(modulePath);
|
|
@@ -11,16 +11,18 @@ var __webpack_modules__ = {
|
|
|
11
11
|
realRequire
|
|
12
12
|
};
|
|
13
13
|
},
|
|
14
|
-
"../../node_modules/.pnpm/thread-stream@4.
|
|
14
|
+
"../../node_modules/.pnpm/thread-stream@4.2.0/node_modules/thread-stream/lib/indexes.js" (module1) {
|
|
15
15
|
"use strict";
|
|
16
|
+
const SEQ_INDEX = 2;
|
|
16
17
|
const WRITE_INDEX = 4;
|
|
17
18
|
const READ_INDEX = 8;
|
|
18
19
|
module1.exports = {
|
|
19
20
|
WRITE_INDEX,
|
|
20
|
-
READ_INDEX
|
|
21
|
+
READ_INDEX,
|
|
22
|
+
SEQ_INDEX
|
|
21
23
|
};
|
|
22
24
|
},
|
|
23
|
-
"../../node_modules/.pnpm/thread-stream@4.
|
|
25
|
+
"../../node_modules/.pnpm/thread-stream@4.2.0/node_modules/thread-stream/lib/wait.js" (module1) {
|
|
24
26
|
"use strict";
|
|
25
27
|
const WAIT_MS = 10000;
|
|
26
28
|
function wait(state, index, expected, timeout, done) {
|
|
@@ -44,7 +46,10 @@ var __webpack_modules__ = {
|
|
|
44
46
|
if (max !== 1 / 0 && Date.now() > max) return void done(null, 'timed-out');
|
|
45
47
|
const remaining = max === 1 / 0 ? WAIT_MS : Math.min(WAIT_MS, Math.max(1, max - Date.now()));
|
|
46
48
|
const result = Atomics.waitAsync(state, index, expected, remaining);
|
|
47
|
-
if (result.async) result.value.then(
|
|
49
|
+
if (result.async) result.value.then((res)=>{
|
|
50
|
+
if ('ok' === res) return void done(null, 'ok');
|
|
51
|
+
check();
|
|
52
|
+
});
|
|
48
53
|
else setImmediate(check);
|
|
49
54
|
};
|
|
50
55
|
check();
|
|
@@ -54,6 +59,10 @@ var __webpack_modules__ = {
|
|
|
54
59
|
waitDiff
|
|
55
60
|
};
|
|
56
61
|
},
|
|
62
|
+
string_decoder (module1) {
|
|
63
|
+
"use strict";
|
|
64
|
+
module1.exports = require("string_decoder");
|
|
65
|
+
},
|
|
57
66
|
worker_threads (module1) {
|
|
58
67
|
"use strict";
|
|
59
68
|
module1.exports = require("worker_threads");
|
|
@@ -72,15 +81,81 @@ function __webpack_require__(moduleId) {
|
|
|
72
81
|
var __webpack_exports__ = {};
|
|
73
82
|
(()=>{
|
|
74
83
|
"use strict";
|
|
75
|
-
const { realImport, realRequire } = __webpack_require__("../../node_modules/.pnpm/real-require@0.
|
|
84
|
+
const { realImport, realRequire } = __webpack_require__("../../node_modules/.pnpm/real-require@1.0.0/node_modules/real-require/src/index.js");
|
|
76
85
|
const { workerData, parentPort } = __webpack_require__("worker_threads");
|
|
77
|
-
const {
|
|
78
|
-
const {
|
|
86
|
+
const { StringDecoder } = __webpack_require__("string_decoder");
|
|
87
|
+
const { WRITE_INDEX, READ_INDEX, SEQ_INDEX } = __webpack_require__("../../node_modules/.pnpm/thread-stream@4.2.0/node_modules/thread-stream/lib/indexes.js");
|
|
88
|
+
const { waitDiff } = __webpack_require__("../../node_modules/.pnpm/thread-stream@4.2.0/node_modules/thread-stream/lib/wait.js");
|
|
79
89
|
const { dataBuf, filename, stateBuf } = workerData;
|
|
80
90
|
let destination;
|
|
91
|
+
const flushQueue = [];
|
|
92
|
+
let flushing = false;
|
|
81
93
|
const state = new Int32Array(stateBuf);
|
|
82
94
|
const data = Buffer.from(dataBuf);
|
|
95
|
+
const decoder = new StringDecoder('utf8');
|
|
83
96
|
const keepAlive = setInterval(()=>{}, 3600000);
|
|
97
|
+
function onParentPortMessage(msg) {
|
|
98
|
+
if (!msg || 'FLUSH' !== msg.code || 'thread-stream' !== msg.context) return;
|
|
99
|
+
flushQueue.push(msg.id);
|
|
100
|
+
processFlushQueue();
|
|
101
|
+
}
|
|
102
|
+
function processFlushQueue() {
|
|
103
|
+
if (flushing || !destination) return;
|
|
104
|
+
const id = flushQueue.shift();
|
|
105
|
+
if (void 0 === id) return;
|
|
106
|
+
flushing = true;
|
|
107
|
+
flushDestination((err)=>{
|
|
108
|
+
flushing = false;
|
|
109
|
+
if (err) return void parentPort.postMessage({
|
|
110
|
+
code: 'ERROR',
|
|
111
|
+
err
|
|
112
|
+
});
|
|
113
|
+
parentPort.postMessage({
|
|
114
|
+
code: 'FLUSHED',
|
|
115
|
+
context: 'thread-stream',
|
|
116
|
+
id
|
|
117
|
+
});
|
|
118
|
+
processFlushQueue();
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function flushDestination(cb) {
|
|
122
|
+
if ('function' == typeof destination?.flush) {
|
|
123
|
+
if (0 === destination.flush.length) {
|
|
124
|
+
try {
|
|
125
|
+
const result = destination.flush();
|
|
126
|
+
if (result && 'function' == typeof result.then) result.then(()=>cb(), cb);
|
|
127
|
+
else cb();
|
|
128
|
+
} catch (err) {
|
|
129
|
+
cb(err);
|
|
130
|
+
}
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
let done = false;
|
|
134
|
+
const onDone = (err)=>{
|
|
135
|
+
if (done) return;
|
|
136
|
+
done = true;
|
|
137
|
+
cb(err);
|
|
138
|
+
};
|
|
139
|
+
try {
|
|
140
|
+
const result = destination.flush(onDone);
|
|
141
|
+
if (result && 'function' == typeof result.then) result.then(()=>onDone(), onDone);
|
|
142
|
+
} catch (err) {
|
|
143
|
+
onDone(err);
|
|
144
|
+
}
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if ('function' == typeof destination?.flushSync) {
|
|
148
|
+
try {
|
|
149
|
+
destination.flushSync();
|
|
150
|
+
cb();
|
|
151
|
+
} catch (err) {
|
|
152
|
+
cb(err);
|
|
153
|
+
}
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (destination?.writableNeedDrain && !destination?.writableEnded) return void destination.once('drain', cb);
|
|
157
|
+
cb();
|
|
158
|
+
}
|
|
84
159
|
async function start() {
|
|
85
160
|
let worker;
|
|
86
161
|
try {
|
|
@@ -124,19 +199,38 @@ var __webpack_exports__ = {};
|
|
|
124
199
|
process.exit(0);
|
|
125
200
|
});
|
|
126
201
|
});
|
|
202
|
+
processFlushQueue();
|
|
127
203
|
}
|
|
128
204
|
start().then(function() {
|
|
205
|
+
parentPort.on('message', onParentPortMessage);
|
|
129
206
|
parentPort.postMessage({
|
|
130
207
|
code: 'READY'
|
|
131
208
|
});
|
|
132
209
|
process.nextTick(run);
|
|
133
210
|
});
|
|
211
|
+
function readState() {
|
|
212
|
+
while(true){
|
|
213
|
+
const seq = Atomics.load(state, SEQ_INDEX);
|
|
214
|
+
if ((1 & seq) !== 0) continue;
|
|
215
|
+
const current = Atomics.load(state, READ_INDEX);
|
|
216
|
+
const end = Atomics.load(state, WRITE_INDEX);
|
|
217
|
+
if (seq === Atomics.load(state, SEQ_INDEX)) return {
|
|
218
|
+
current,
|
|
219
|
+
end,
|
|
220
|
+
seq
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
}
|
|
134
224
|
function run() {
|
|
135
|
-
const current =
|
|
136
|
-
|
|
137
|
-
if (
|
|
138
|
-
|
|
139
|
-
|
|
225
|
+
const { current, end, seq } = readState();
|
|
226
|
+
if (end === current) return void waitDiff(state, SEQ_INDEX, seq, 1 / 0, run);
|
|
227
|
+
if (-1 === end) {
|
|
228
|
+
const remaining = decoder.end();
|
|
229
|
+
if (remaining.length > 0) destination.write(remaining);
|
|
230
|
+
destination.end();
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
const toWrite = decoder.write(data.subarray(current, end));
|
|
140
234
|
const res = destination.write(toWrite);
|
|
141
235
|
if (res) {
|
|
142
236
|
Atomics.store(state, READ_INDEX, end);
|
package/dist/cjs/trace.cjs
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
9
13
|
};
|
|
10
14
|
})();
|
|
11
15
|
(()=>{
|
|
@@ -24,9 +28,9 @@ var __webpack_require__ = {};
|
|
|
24
28
|
var __webpack_exports__ = {};
|
|
25
29
|
__webpack_require__.r(__webpack_exports__);
|
|
26
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
|
|
31
|
+
genTraceId: ()=>genTraceId,
|
|
28
32
|
getTraceId: ()=>getTraceId,
|
|
29
|
-
|
|
33
|
+
runInTrace: ()=>runInTrace
|
|
30
34
|
});
|
|
31
35
|
const external_async_hooks_namespaceObject = require("async_hooks");
|
|
32
36
|
const als = new external_async_hooks_namespaceObject.AsyncLocalStorage();
|
package/dist/esm/common.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
4
|
-
var
|
|
5
|
-
const isEsm = '.mjs' === path.extname(
|
|
4
|
+
var __rspack_import_meta_filename__ = __rspack_fileURLToPath(import.meta.url);
|
|
5
|
+
const isEsm = '.mjs' === path.extname(__rspack_import_meta_filename__);
|
|
6
6
|
const isCjs = !isEsm;
|
|
7
7
|
export { isCjs, isEsm };
|
package/dist/esm/pino/index.mjs
CHANGED
|
@@ -5,17 +5,17 @@ import { genTraceId, getTraceId, runInTrace } from "../trace.mjs";
|
|
|
5
5
|
import { __webpack_require__ } from "../rslib-runtime.mjs";
|
|
6
6
|
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
7
7
|
import { dirname as __rspack_dirname } from "node:path";
|
|
8
|
-
|
|
8
|
+
var __rspack_import_meta_filename__ = __rspack_fileURLToPath(import.meta.url);
|
|
9
|
+
var __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
10
|
+
import * as __rspack_external_pino_std_serializers_c7d9cf2d from "pino-std-serializers";
|
|
9
11
|
__webpack_require__.add({
|
|
10
12
|
"pino-std-serializers" (module) {
|
|
11
|
-
module.exports =
|
|
13
|
+
module.exports = __rspack_external_pino_std_serializers_c7d9cf2d;
|
|
12
14
|
}
|
|
13
15
|
});
|
|
14
|
-
var pino_filename = __rspack_fileURLToPath(import.meta.url);
|
|
15
|
-
var pino_dirname = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
16
16
|
function getPinoConfig() {
|
|
17
17
|
const targets = [];
|
|
18
|
-
const rotate = `./rotate${path.extname(
|
|
18
|
+
const rotate = `./rotate${path.extname(__rspack_import_meta_filename__)}`;
|
|
19
19
|
targets.push({
|
|
20
20
|
level: 'debug',
|
|
21
21
|
target: rotate,
|
|
@@ -24,11 +24,11 @@ function getPinoConfig() {
|
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
26
|
if ("u" > typeof __isNodeSingleFileBundle || "u" > typeof __isVite || global?.__remix_devServerHooks || 'development' !== process.env.NODE_ENV) globalThis.__bundlerPathsOverrides = {
|
|
27
|
-
'pino-pretty': path.join(
|
|
28
|
-
'pino-worker': path.join(
|
|
29
|
-
[rotate]: path.join(
|
|
30
|
-
'pino/file': path.join(
|
|
31
|
-
'thread-stream-worker': path.join(
|
|
27
|
+
'pino-pretty': path.join(__rspack_import_meta_dirname__, './worker/pino-pretty.cjs'),
|
|
28
|
+
'pino-worker': path.join(__rspack_import_meta_dirname__, './worker/pino-worker.cjs'),
|
|
29
|
+
[rotate]: path.join(__rspack_import_meta_dirname__, './worker/pino-rotate.cjs'),
|
|
30
|
+
'pino/file': path.join(__rspack_import_meta_dirname__, './worker/pino-file.cjs'),
|
|
31
|
+
'thread-stream-worker': path.join(__rspack_import_meta_dirname__, './worker/thread-stream.cjs'),
|
|
32
32
|
...globalThis.__bundlerPathsOverrides
|
|
33
33
|
};
|
|
34
34
|
'production' === process.env.NODE_ENV || void 0 !== process.env.VITEST || targets.push({
|
|
@@ -49,7 +49,6 @@ function getPinoConfig() {
|
|
|
49
49
|
delete data.level;
|
|
50
50
|
delete data.time;
|
|
51
51
|
delete data.pid;
|
|
52
|
-
delete data.name;
|
|
53
52
|
delete data.hostname;
|
|
54
53
|
if (!traceId) return {
|
|
55
54
|
traceId: getTraceId()
|
|
@@ -59,12 +58,30 @@ function getPinoConfig() {
|
|
|
59
58
|
};
|
|
60
59
|
},
|
|
61
60
|
browser: {
|
|
61
|
+
serialize: true,
|
|
62
62
|
write: (o)=>{
|
|
63
|
-
const {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
const { fn, time, level, ...rest } = o;
|
|
64
|
+
const clone = {
|
|
65
|
+
...o
|
|
66
|
+
};
|
|
67
|
+
if (fn) rest.message = rest.message ? `[${fn}] ${rest.message}` : `[${fn}]`;
|
|
68
|
+
if (!rest.traceId) {
|
|
69
|
+
rest.traceId = getTraceId();
|
|
70
|
+
clone.traceId = getTraceId();
|
|
71
|
+
}
|
|
72
|
+
if (level >= 50) {
|
|
73
|
+
const keys = [
|
|
74
|
+
'fn',
|
|
75
|
+
'time',
|
|
76
|
+
'level'
|
|
77
|
+
];
|
|
78
|
+
keys.forEach((k)=>delete clone[k]);
|
|
79
|
+
if (clone.msg) {
|
|
80
|
+
clone.msg = `${clone.name || 'Error'}: ${clone.msg}`;
|
|
81
|
+
if (fn) clone.msg = `[${fn}] ${clone.msg}`;
|
|
82
|
+
}
|
|
83
|
+
console.error(clone);
|
|
84
|
+
} else if (level >= 40) console.warn(rest);
|
|
68
85
|
else console.log(rest);
|
|
69
86
|
}
|
|
70
87
|
}
|
package/dist/esm/pino/rotate.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import { __webpack_require__ } from "../rslib-runtime.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as __rspack_external_rotating_file_stream_a9540b88 from "rotating-file-stream";
|
|
4
4
|
__webpack_require__.add({
|
|
5
5
|
"rotating-file-stream" (module) {
|
|
6
|
-
module.exports =
|
|
6
|
+
module.exports = __rspack_external_rotating_file_stream_a9540b88;
|
|
7
7
|
}
|
|
8
8
|
});
|
|
9
9
|
const generator = (time, index)=>{
|