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'); }