44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
/* eslint-disable no-console */
|
|
// const { MasterLogger } = require('../build');
|
|
// const ChildProcess = require('node:child_process');
|
|
import { MasterLogger } from "../build/index.js";
|
|
import ChildProcess from "node:child_process";
|
|
|
|
const spawn = (child) => {
|
|
return new Promise((resolve) => {
|
|
child.on('spawn', resolve);
|
|
});
|
|
|
|
};
|
|
|
|
const main = async () => {
|
|
const logger = new MasterLogger({
|
|
debug: true,
|
|
customTypes: [ 'access' ],
|
|
customStreams: [ 'access' ],
|
|
customTypeMapping: { access: 'access', warn: 'error' },
|
|
customColors: {
|
|
access: 'green',
|
|
// error: '#FF0000'
|
|
},
|
|
fileRotationFreq: 0.0001,
|
|
logLevelMapping: { access: 2 },
|
|
broadcastLevel: 3,
|
|
webhook: {
|
|
url: 'https://discord.com/api/webhooks/1093874668886294548/uDMRD6g1lmq_2EZynsbKytzWoMM-0N4te0m61r_cv1BsSnDKDxG3fvI6sxSoG5t5b_xn'
|
|
}
|
|
});
|
|
const child = ChildProcess.fork('./test/otherProcess.js');
|
|
logger.attach(child);
|
|
|
|
await spawn(child);
|
|
|
|
const { types, colours, streamTypes, streamTypeMapping } = logger; // , writeStreams
|
|
console.log(types, colours, streamTypes, streamTypeMapping); // , writeStreams
|
|
|
|
for (let i = 0; i < 10; i++) {
|
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
logger.info(`Iteration ${i}`);
|
|
}
|
|
};
|
|
main(); |