safesupport-bot/dist/logger.js

41 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2020-03-16 18:41:56 +00:00
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
2020-03-16 18:41:56 +00:00
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
2020-03-16 18:41:56 +00:00
var _winston = _interopRequireDefault(require("winston"));
const logger = _winston.default.createLogger({
2020-03-16 18:41:56 +00:00
level: "info",
format: _winston.default.format.json(),
2020-03-16 18:41:56 +00:00
defaultMeta: {
service: "user-service"
},
transports: [//
// - Write all logs with level `error` and below to `error.log`
// - Write all logs with level `info` and below to `combined.log`
//
new _winston.default.transports.File({
2020-03-16 18:41:56 +00:00
filename: "error.log",
level: "error"
}), new _winston.default.transports.File({
2020-03-16 18:41:56 +00:00
filename: "combined.log"
})]
}); //
// If we're not in production then log to the `console` with the format:
// `${info.level}: ${info.message} JSON.stringify({ ...rest }) `
//
if (process.env.NODE_ENV !== "production") {
logger.add(new _winston.default.transports.Console({
format: _winston.default.format.simple()
2020-03-16 18:41:56 +00:00
}));
}
var _default = logger;
exports.default = _default;