fluxion-ts 0.3.3 → 0.4.1
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/README.md +2 -0
- package/dist/index.cjs +32 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +32 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -79,6 +79,8 @@ In this repository, `pnpm dev` runs `src/index.ts` directly and starts Fluxion u
|
|
|
79
79
|
Default development options:
|
|
80
80
|
|
|
81
81
|
```ts
|
|
82
|
+
// if process.env.FLUXION_COLORS === '0', colors will be disabled in logs
|
|
83
|
+
|
|
82
84
|
fluxion({
|
|
83
85
|
dir: process.env.DYNAMIC_DIRECTORY ?? 'dynamicDirectory',
|
|
84
86
|
host: process.env.HOST ?? 'localhost',
|
package/dist/index.cjs
CHANGED
|
@@ -167,6 +167,35 @@ function createLogger(cx) {
|
|
|
167
167
|
};
|
|
168
168
|
return logger;
|
|
169
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Create a worker logger that prefixes all log messages with the worker PID.
|
|
172
|
+
*/
|
|
173
|
+
function createWorkerLogger(baseLogger, pid) {
|
|
174
|
+
const pidPrefix = `[${pid}]`;
|
|
175
|
+
return {
|
|
176
|
+
write(level, event, fields) {
|
|
177
|
+
baseLogger.write(level, `${pidPrefix} ${event}`, fields);
|
|
178
|
+
},
|
|
179
|
+
info(event, fields) {
|
|
180
|
+
baseLogger.info(`${pidPrefix} ${event}`, fields);
|
|
181
|
+
},
|
|
182
|
+
warn(event, fields) {
|
|
183
|
+
baseLogger.warn(`${pidPrefix} ${event}`, fields);
|
|
184
|
+
},
|
|
185
|
+
error(event, fields) {
|
|
186
|
+
baseLogger.error(`${pidPrefix} ${event}`, fields);
|
|
187
|
+
},
|
|
188
|
+
succ(event, fields) {
|
|
189
|
+
baseLogger.succ(`${pidPrefix} ${event}`, fields);
|
|
190
|
+
},
|
|
191
|
+
debug(event, fields) {
|
|
192
|
+
baseLogger.debug(`${pidPrefix} ${event}`, fields);
|
|
193
|
+
},
|
|
194
|
+
verbose(event, fields) {
|
|
195
|
+
baseLogger.verbose(`${pidPrefix} ${event}`, fields);
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
}
|
|
170
199
|
/**
|
|
171
200
|
* ! Error.isError needs Node.js 24
|
|
172
201
|
*/
|
|
@@ -957,7 +986,7 @@ const inject = async (cx) => {
|
|
|
957
986
|
const instance = await PromiseTry(factory);
|
|
958
987
|
o[injection.name] = instance;
|
|
959
988
|
}
|
|
960
|
-
cx.logger.info(
|
|
989
|
+
cx.logger.info('injections loaded', Object.keys(o));
|
|
961
990
|
};
|
|
962
991
|
const startStatsReporter = () => {
|
|
963
992
|
let previousCpuUsage = process.cpuUsage();
|
|
@@ -3636,6 +3665,8 @@ async function fluxion(options) {
|
|
|
3636
3665
|
initPrimary(context);
|
|
3637
3666
|
}
|
|
3638
3667
|
else {
|
|
3668
|
+
// Replace logger with worker logger that prefixes PID
|
|
3669
|
+
context.logger = createWorkerLogger(context.logger, process.pid);
|
|
3639
3670
|
// Only worker creates the watcher
|
|
3640
3671
|
context.watcher = new FluxionWatcher(context).start();
|
|
3641
3672
|
initWorker(context);
|