iccicci / rotating-file-stream

Opens a stream.Writable to a file rotated by interval and/or size. A logrotate alternative.
MIT License
285 stars 38 forks source link

Question: how to set folder to store file? #102

Closed linonetwo closed 5 months ago

linonetwo commented 5 months ago

I used to

import settings from 'electron-settings';
import * as rotateFs from 'rotating-file-stream';

//...
      this.settingBackupStream = rotateFs.createStream(`${settings.file()}.bak`, {
        size: '10M',
        interval: '1d',
        maxFiles: 3,
      });

And it causes

{"code":"ENOENT","errno":-4058,"level":"error","path":"C:\Users\linonetwo\AppData\Local\tidgi\app-0.9.4\20240418-0000-01-C:\Users\linonetwo\AppData\Roaming\TidGi\settings","syscall":"mkdir","timestamp":"2024-04-17T16:02:10.014Z"}

So I have to only use rotateFs.createStream('settings.json.bak', but how to control where to store this file?

linonetwo commented 5 months ago

Use https://github.com/iccicci/rotating-file-stream?tab=readme-ov-file#path