Git Product home page Git Product logo

Comments (4)

BARMPlus avatar BARMPlus commented on July 17, 2024

@iccicci need your help

from rotating-file-stream.

iccicci avatar iccicci commented on July 17, 2024

Hi @BARMPlus ,

I run this and I got no errors.

const path = require("path");
const { createStream } = require("rotating-file-stream");

const dir = "test";

const generator = (time, index) => {
  const name = "web.log";
  if(! time) return name;
  const pad = num => (num > 9 ? "" : "0") + num;
  const month = time.getFullYear() + "" + pad(time.getMonth() + 1);
  const day = pad(time.getDate());
  return `history/${month}${day}-${index}-${name}`;
};

const options = {
  maxFiles: 7,
  interval: "2s",
  path:     path.resolve(process.cwd(), dir)
};

const stream = createStream(generator, options);

setTimeout(() => {}, 600000);

let count = 0;

function write() {
  stream.write(`write ${++count}\n`);
  setTimeout(write, Math.random() * 10).unref();
}

write();

I'm sorry but I didn't got the point when you say:

When I request access to the log when I am about to rename the log, it is easy to get the above error.

If you meant you want to access the log file you are writing you might consider the immutable options or the rotation and rotated events: you may stop trying to access the log file between a rotation and a rotated events.

from rotating-file-stream.

BARMPlus avatar BARMPlus commented on July 17, 2024

Thank you, it's my problem, it has been solved

from rotating-file-stream.

zhongshanxian avatar zhongshanxian commented on July 17, 2024

I got save error, how do you resolve ?

from rotating-file-stream.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.