12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- var moment = require('moment');
- const symLinkName = "tail.log"
- var rotatingLogStream = require('../FileStreamRotator').getStream({
- filename: "logs/1m/testlog-%DATE%",
- frequency: "1m",
- verbose: true,
- date_format: "YYYY-MM-DD.HH.mm",
- size: "100k",
- max_logs: "10",
- audit_file: "/tmp/audit.json",
- end_stream: false,
- utc: true,
- extension: ".log",
- create_symlink: true,
- watch_log: true,
-
- symlink_name: symLinkName
- });
- rotatingLogStream.on("error", function () {
- console.log(Date.now(), Date(), "stream error", arguments)
- })
- rotatingLogStream.on("close", function () {
- console.log(Date.now(), Date(), "stream closed")
- })
- rotatingLogStream.on("finish", function () {
- console.log(Date.now(), Date(), "stream finished")
- })
- rotatingLogStream.on("rotate", function (oldFile, newFile) {
- console.log(Date.now(), Date(), "stream rotated", oldFile, newFile);
- })
- rotatingLogStream.on("open", function (fd) {
- console.log(Date.now(), Date(), "stream open", fd);
- })
- rotatingLogStream.on("new", function (newFile) {
- console.log(Date.now(), Date(), "stream new", newFile);
- })
- rotatingLogStream.on("logRemoved", function (newFile) {
- console.log(Date.now(), Date(), "stream logRemoved", newFile);
- })
- var counter = 0;
- var i = setInterval(function () {
- counter++;
- rotatingLogStream.write(Date() + "\t" + "testing 1234567890-testing 1234567890-testing 1234567890-testing 1234567890-testing 1234567890-testing 1234567890-testing 1234567890-testing 1234567890-testing 1234567890-testing 1234567890-testing 1234567890-testing 1234567890-testing 1234567890-testing 1234567890-testing 1234567890-testing 1234567890-testing 1234567890-testing 1234567890-testing 1234567890-testing 1234567890-testing 1234567890-testing 1234567890-testing 1234567890-testing 1234567890-testing 1234567890-testing 1234567890-testing 1234567890-testing 1234567890-testing 1234567890-testing 1234567890\n")
-
- if (counter == 5000) {
- clearInterval(i);
- rotatingLogStream.end("end\n");
-
- }
- }, 10);
|