How to use rotating-file-stream - 4 common examples

To help you get started, we’ve selected a few rotating-file-stream examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CodeChain-io / codechain-exchange / app.ts View on Github external
import * as bodyParser from "body-parser";
import * as express from "express";
import * as logger from "morgan";
import * as path from "path";
import rfs from "rotating-file-stream";
import route from "./server/routes";

// Set up the express app
const app = express();

// Log requests to the console.
app.use(logger("dev"));

// create a rotating write stream
const accessLogStream = rfs("access.log", {
  interval: "1d", // rotate daily
  path: path.join(__dirname, "log")
});

// setup the logger
app.use(logger("combined", { stream: accessLogStream }));

// Parse incoming requests data (https://github.com/expressjs/body-parser)
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));

const cors = require("cors");
app.use(cors());
// Setup a default catch-all route that sends back a welcome message in JSON format.
route(app);
github labzero / lunch / src / server.js View on Github external
import api from './api';
import { sequelize } from './models/db';
import { Team, User } from './models';

fetch.promise = Promise;

const app = express();

const logDirectory = path.join(__dirname, 'log');

// ensure log directory exists
// eslint-disable-next-line no-unused-expressions
fs.existsSync(logDirectory) || fs.mkdirSync(logDirectory);

// create a rotating write stream
const accessLogStream = rfs('access.log', {
  interval: '1d', // rotate daily
  path: logDirectory
});

export const wsServer = new HttpServer(app);

//
// Tell any CSS tooling (such as Material UI) to use all vendor prefixes if the
// user agent is not known.
// -----------------------------------------------------------------------------
global.navigator = global.navigator || {};
global.navigator.userAgent = global.navigator.userAgent || 'all';

//
// Register Node.js middleware
// -----------------------------------------------------------------------------
github ArkEcosystem / core / packages / core-logger-pino / src / driver.ts View on Github external
private getFileStream(): WriteStream {
        const createFileName = (time: Date, index: number) => {
            if (!time) {
                return `${app.getName()}-current.log`;
            }

            let filename = time.toISOString().slice(0, 10);
            if (index > 1) {
                filename += `.${index}`;
            }

            return `${app.getName()}-${filename}.log.gz`;
        };

        return rfs(createFileName, {
            path: process.env.CORE_PATH_LOG,
            initialRotation: true,
            interval: this.options.fileRotator ? this.options.fileRotator.interval : "1d",
            maxSize: "100M",
            maxFiles: 10,
            compress: "gzip",
        });
    }
}
github felixbrucker / foxy-proxy / lib / services / logger.js View on Github external
enableFileLogging() {
    if (this.logWriter) {
      return;
    }

    this.logWriter = rfs.createStream(Logger.logFileGenerator, {
      size: '10M',
      interval: '1d',
      path: store.getLogDir(),
    });
  }

rotating-file-stream

Opens a stream.Writable to a file rotated by interval and/or size. A logrotate alternative.

MIT
Latest version published 4 months ago

Package Health Score

73 / 100
Full package analysis

Popular rotating-file-stream functions