@rife/logger 0.0.6-beta.10 → 0.0.6-beta.11
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 +118 -67
- package/dist/cjs/pino/worker/pino-file.cjs +3353 -0
- package/dist/cjs/pino/worker/pino-pretty.cjs +2870 -0
- package/dist/cjs/pino/worker/pino-rotate.cjs +604 -0
- package/dist/cjs/pino/worker/pino-worker.cjs +3666 -0
- package/dist/cjs/pino/worker/thread-stream.cjs +172 -0
- package/dist/cjs/test.cjs +5 -5
- package/dist/cjs/trace.cjs +1 -1
- package/dist/esm/pino/index.mjs +61 -12
- package/dist/esm/pino/worker/pino-file.cjs +3353 -0
- package/dist/esm/pino/worker/pino-pretty.cjs +2870 -0
- package/dist/esm/pino/worker/pino-rotate.cjs +604 -0
- package/dist/esm/pino/worker/pino-worker.cjs +3666 -0
- package/dist/esm/pino/worker/thread-stream.cjs +172 -0
- package/dist/esm/test.mjs +5 -5
- package/dist/worker/pino-file.cjs +428 -597
- package/dist/worker/pino-pretty.cjs +290 -276
- package/dist/worker/pino-rotate.cjs +2 -2
- package/dist/worker/pino-worker.cjs +497 -666
- package/package.json +6 -6
- package/src/common.ts +4 -4
- package/src/pino/index.ts +120 -102
- package/src/pino/rotate.ts +32 -32
- package/src/test.ts +19 -19
- package/src/trace.ts +15 -15
- package/tsconfig.json +12 -12
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
var __webpack_modules__ = {
|
|
2
|
+
"../../node_modules/.pnpm/real-require@0.2.0/node_modules/real-require/src/index.js": function(module1) {
|
|
3
|
+
const realImport = new Function('modulePath', 'return import(modulePath)');
|
|
4
|
+
function realRequire(modulePath) {
|
|
5
|
+
if ('function' == typeof __non_webpack__require__) return __non_webpack__require__(modulePath);
|
|
6
|
+
return require(modulePath);
|
|
7
|
+
}
|
|
8
|
+
module1.exports = {
|
|
9
|
+
realImport,
|
|
10
|
+
realRequire
|
|
11
|
+
};
|
|
12
|
+
},
|
|
13
|
+
"../../node_modules/.pnpm/thread-stream@3.1.0/node_modules/thread-stream/lib/indexes.js": function(module1) {
|
|
14
|
+
"use strict";
|
|
15
|
+
const WRITE_INDEX = 4;
|
|
16
|
+
const READ_INDEX = 8;
|
|
17
|
+
module1.exports = {
|
|
18
|
+
WRITE_INDEX,
|
|
19
|
+
READ_INDEX
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
"../../node_modules/.pnpm/thread-stream@3.1.0/node_modules/thread-stream/lib/wait.js": function(module1) {
|
|
23
|
+
"use strict";
|
|
24
|
+
const MAX_TIMEOUT = 1000;
|
|
25
|
+
function wait(state, index, expected, timeout, done) {
|
|
26
|
+
const max = Date.now() + timeout;
|
|
27
|
+
let current = Atomics.load(state, index);
|
|
28
|
+
if (current === expected) return void done(null, 'ok');
|
|
29
|
+
let prior = current;
|
|
30
|
+
const check = (backoff)=>{
|
|
31
|
+
if (Date.now() > max) done(null, 'timed-out');
|
|
32
|
+
else setTimeout(()=>{
|
|
33
|
+
prior = current;
|
|
34
|
+
current = Atomics.load(state, index);
|
|
35
|
+
if (current === prior) check(backoff >= MAX_TIMEOUT ? MAX_TIMEOUT : 2 * backoff);
|
|
36
|
+
else current === expected ? done(null, 'ok') : done(null, 'not-equal');
|
|
37
|
+
}, backoff);
|
|
38
|
+
};
|
|
39
|
+
check(1);
|
|
40
|
+
}
|
|
41
|
+
function waitDiff(state, index, expected, timeout, done) {
|
|
42
|
+
const max = Date.now() + timeout;
|
|
43
|
+
let current = Atomics.load(state, index);
|
|
44
|
+
if (current !== expected) return void done(null, 'ok');
|
|
45
|
+
const check = (backoff)=>{
|
|
46
|
+
if (Date.now() > max) done(null, 'timed-out');
|
|
47
|
+
else setTimeout(()=>{
|
|
48
|
+
current = Atomics.load(state, index);
|
|
49
|
+
if (current !== expected) done(null, 'ok');
|
|
50
|
+
else check(backoff >= MAX_TIMEOUT ? MAX_TIMEOUT : 2 * backoff);
|
|
51
|
+
}, backoff);
|
|
52
|
+
};
|
|
53
|
+
check(1);
|
|
54
|
+
}
|
|
55
|
+
module1.exports = {
|
|
56
|
+
wait,
|
|
57
|
+
waitDiff
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
worker_threads: function(module1) {
|
|
61
|
+
"use strict";
|
|
62
|
+
module1.exports = require("worker_threads");
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
var __webpack_module_cache__ = {};
|
|
66
|
+
function __webpack_require__(moduleId) {
|
|
67
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
68
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
69
|
+
var module1 = __webpack_module_cache__[moduleId] = {
|
|
70
|
+
exports: {}
|
|
71
|
+
};
|
|
72
|
+
__webpack_modules__[moduleId](module1, module1.exports, __webpack_require__);
|
|
73
|
+
return module1.exports;
|
|
74
|
+
}
|
|
75
|
+
var __webpack_exports__ = {};
|
|
76
|
+
(()=>{
|
|
77
|
+
"use strict";
|
|
78
|
+
const { realImport, realRequire } = __webpack_require__("../../node_modules/.pnpm/real-require@0.2.0/node_modules/real-require/src/index.js");
|
|
79
|
+
const { workerData, parentPort } = __webpack_require__("worker_threads");
|
|
80
|
+
const { WRITE_INDEX, READ_INDEX } = __webpack_require__("../../node_modules/.pnpm/thread-stream@3.1.0/node_modules/thread-stream/lib/indexes.js");
|
|
81
|
+
const { waitDiff } = __webpack_require__("../../node_modules/.pnpm/thread-stream@3.1.0/node_modules/thread-stream/lib/wait.js");
|
|
82
|
+
const { dataBuf, filename, stateBuf } = workerData;
|
|
83
|
+
let destination;
|
|
84
|
+
const state = new Int32Array(stateBuf);
|
|
85
|
+
const data = Buffer.from(dataBuf);
|
|
86
|
+
async function start() {
|
|
87
|
+
let worker;
|
|
88
|
+
try {
|
|
89
|
+
if (filename.endsWith('.ts') || filename.endsWith('.cts')) {
|
|
90
|
+
if (process[Symbol.for('ts-node.register.instance')]) {
|
|
91
|
+
if (process.env.TS_NODE_DEV) realRequire('ts-node-dev');
|
|
92
|
+
} else realRequire('ts-node/register');
|
|
93
|
+
worker = realRequire(decodeURIComponent(filename.replace('win32' === process.platform ? 'file:///' : 'file://', '')));
|
|
94
|
+
} else worker = await realImport(filename);
|
|
95
|
+
} catch (error) {
|
|
96
|
+
if (('ENOTDIR' === error.code || 'ERR_MODULE_NOT_FOUND' === error.code) && filename.startsWith('file://')) worker = realRequire(decodeURIComponent(filename.replace('file://', '')));
|
|
97
|
+
else if (void 0 === error.code || 'ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING' === error.code) try {
|
|
98
|
+
worker = realRequire(decodeURIComponent(filename.replace('win32' === process.platform ? 'file:///' : 'file://', '')));
|
|
99
|
+
} catch {
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
else throw error;
|
|
103
|
+
}
|
|
104
|
+
if ('object' == typeof worker) worker = worker.default;
|
|
105
|
+
if ('object' == typeof worker) worker = worker.default;
|
|
106
|
+
destination = await worker(workerData.workerData);
|
|
107
|
+
destination.on('error', function(err) {
|
|
108
|
+
Atomics.store(state, WRITE_INDEX, -2);
|
|
109
|
+
Atomics.notify(state, WRITE_INDEX);
|
|
110
|
+
Atomics.store(state, READ_INDEX, -2);
|
|
111
|
+
Atomics.notify(state, READ_INDEX);
|
|
112
|
+
parentPort.postMessage({
|
|
113
|
+
code: 'ERROR',
|
|
114
|
+
err
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
destination.on('close', function() {
|
|
118
|
+
const end = Atomics.load(state, WRITE_INDEX);
|
|
119
|
+
Atomics.store(state, READ_INDEX, end);
|
|
120
|
+
Atomics.notify(state, READ_INDEX);
|
|
121
|
+
setImmediate(()=>{
|
|
122
|
+
process.exit(0);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
start().then(function() {
|
|
127
|
+
parentPort.postMessage({
|
|
128
|
+
code: 'READY'
|
|
129
|
+
});
|
|
130
|
+
process.nextTick(run);
|
|
131
|
+
});
|
|
132
|
+
function run() {
|
|
133
|
+
const current = Atomics.load(state, READ_INDEX);
|
|
134
|
+
const end = Atomics.load(state, WRITE_INDEX);
|
|
135
|
+
if (end === current) return void (end === data.length ? waitDiff(state, READ_INDEX, end, 1 / 0, run) : waitDiff(state, WRITE_INDEX, end, 1 / 0, run));
|
|
136
|
+
if (-1 === end) return void destination.end();
|
|
137
|
+
const toWrite = data.toString('utf8', current, end);
|
|
138
|
+
const res = destination.write(toWrite);
|
|
139
|
+
if (res) {
|
|
140
|
+
Atomics.store(state, READ_INDEX, end);
|
|
141
|
+
Atomics.notify(state, READ_INDEX);
|
|
142
|
+
setImmediate(run);
|
|
143
|
+
} else destination.once('drain', function() {
|
|
144
|
+
Atomics.store(state, READ_INDEX, end);
|
|
145
|
+
Atomics.notify(state, READ_INDEX);
|
|
146
|
+
run();
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
process.on('unhandledRejection', function(err) {
|
|
150
|
+
parentPort.postMessage({
|
|
151
|
+
code: 'ERROR',
|
|
152
|
+
err
|
|
153
|
+
});
|
|
154
|
+
process.exit(1);
|
|
155
|
+
});
|
|
156
|
+
process.on('uncaughtException', function(err) {
|
|
157
|
+
parentPort.postMessage({
|
|
158
|
+
code: 'ERROR',
|
|
159
|
+
err
|
|
160
|
+
});
|
|
161
|
+
process.exit(1);
|
|
162
|
+
});
|
|
163
|
+
process.once('exit', (exitCode)=>{
|
|
164
|
+
if (0 !== exitCode) return void process.exit(exitCode);
|
|
165
|
+
if (destination?.writableNeedDrain && !destination?.writableEnded) parentPort.postMessage({
|
|
166
|
+
code: 'WARNING',
|
|
167
|
+
err: new Error('ThreadStream: process exited before destination stream was drained. this may indicate that the destination stream try to write to a another missing stream')
|
|
168
|
+
});
|
|
169
|
+
process.exit(0);
|
|
170
|
+
});
|
|
171
|
+
})();
|
|
172
|
+
module.exports = __webpack_exports__;
|
package/dist/esm/test.mjs
CHANGED
|
@@ -18,11 +18,6 @@ const log = logger.child({
|
|
|
18
18
|
}, {
|
|
19
19
|
msgPrefix: '[123] '
|
|
20
20
|
});
|
|
21
|
-
log.info(2);
|
|
22
|
-
log.info({
|
|
23
|
-
c: 1,
|
|
24
|
-
name: '========'
|
|
25
|
-
}, 'name overide');
|
|
26
21
|
log.error(new Error('cause', {
|
|
27
22
|
cause: new Error('789')
|
|
28
23
|
}));
|
|
@@ -30,3 +25,8 @@ log.error({
|
|
|
30
25
|
error: new Error('error data'),
|
|
31
26
|
data: 2
|
|
32
27
|
});
|
|
28
|
+
log.info({
|
|
29
|
+
c: 1,
|
|
30
|
+
name: '========'
|
|
31
|
+
}, 'name overide');
|
|
32
|
+
log.info(1);
|