logger.js 620 Bytes
"use strict";

const winston = require("winston");
const winstonCircularBuffer = require("winston-circular-buffer");
const strftime = require("strftime");

const config = require("./config");

const logger = new (winston.Logger)({
  transports: [
    new (winston.transports.Console)({
        timestamp: function() {
            return strftime('%F %T', new Date());
        },
        level: config.log_level || "info"
    }),

    new (winston.transports.CircularBuffer)({
        name: 'logs',
        level: config.log_level || "info",
        json: true,
        size: 200
    })
  ]
});

module.exports = logger;