@bcc-code/feathers-arangodb
Version:
ArangoDB Service/Adapter for FeathersJS
36 lines (35 loc) • 1.6 kB
JavaScript
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
const winston_1 = require("winston");
const logging_winston_1 = require("@google-cloud/logging-winston");
const isLocalEnvironment = process.env.NODE_ENV !== 'production';
const serviceName = isLocalEnvironment ? 'development' : process.env.K_SERVICE;
const desiredLogLevel = process.env.LOGGING_LEVEL || 'debug';
const logFormat = winston_1.format.printf(function (info) {
const { level, message } = info, json = __rest(info, ["level", "message"]);
return `${level}: ${message} ${JSON.stringify(json, null, 4)}\n`;
});
const consoleTransport = new winston_1.transports.Console({
level: desiredLogLevel,
format: winston_1.format.combine(winston_1.format.colorize(), logFormat),
});
const loggingWinston = new logging_winston_1.LoggingWinston({
level: desiredLogLevel,
logName: `${serviceName}-FeathersArangoAdapter-logs`,
});
const logger = (0, winston_1.createLogger)({
transports: isLocalEnvironment ? [consoleTransport] : [loggingWinston],
});
logger.level = desiredLogLevel;
exports.default = logger;
;