colyseus-server-stress-tester/logger.js
2022-08-04 09:56:05 +08:00

19 lines
556 B
JavaScript

import { createWriteStream } from 'fs';
import { fileURLToPath } from 'url';
import { dirname } from 'path';
const statefileStream = createWriteStream(
`${dirname(fileURLToPath(import.meta.url))}/logs/state.log`,
{ flags: 'w' },
);
const erroutfileStream = createWriteStream(
`${dirname(fileURLToPath(import.meta.url))}/logs/error.log`,
{ flags: 'w' },
);
export const writeLine = (obj) => {
statefileStream.write(JSON.stringify(obj) + '\n');
}
export const logError = (...args) => {
erroutfileStream.write(JSON.stringify(args) + '\n');
}