41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
"use strict";
|
|
|
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = void 0;
|
|
|
|
var _winston = _interopRequireDefault(require("winston"));
|
|
|
|
const logger = _winston.default.createLogger({
|
|
level: "info",
|
|
format: _winston.default.format.json(),
|
|
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({
|
|
filename: "error.log",
|
|
level: "error"
|
|
}), new _winston.default.transports.File({
|
|
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()
|
|
}));
|
|
}
|
|
|
|
var _default = logger;
|
|
exports.default = _default; |