@natlibfi/melinda-merge-ui-commons
Version:
Common modules for Melinda Merge UI application
70 lines (60 loc) • 4.54 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.expressWinston = exports.logger = undefined;
var _moment = require('moment');
var _moment2 = _interopRequireDefault(_moment);
var _winston = require('winston');
var _winston2 = _interopRequireDefault(_winston);
var _expressWinston = require('express-winston');
var _expressWinston2 = _interopRequireDefault(_expressWinston);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var LOGLEVEL = process.env.NODE_ENV == 'debug' ? 'debug' : 'info'; /**
*
* @licstart The following is the entire license notice for the JavaScript code in this file.
*
* Common modules for Melinda UI applications
*
* Copyright (C) 2015-2019 University Of Helsinki (The National Library Of Finland)
*
* This file is part of melinda-ui-commons
*
* melinda-ui-commons program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* melinda-ui-commons is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @licend The above is the entire license notice
* for the JavaScript code in this file.
*
*/
var logger = exports.logger = new _winston2.default.Logger({
transports: [new _winston2.default.transports.Console({
'timestamp': function timestamp() {
return (0, _moment2.default)().format();
},
'level': LOGLEVEL
})]
});
var expressWinston = exports.expressWinston = _expressWinston2.default.logger({
transports: [new _winston2.default.transports.Console({
'timestamp': function timestamp() {
return (0, _moment2.default)().format();
},
'level': LOGLEVEL
})],
meta: true // optional: control whether you want to log the meta data about the request (default to true)
//msg: "HTTP {{req.method}} {{req.url}}", // optional: customize the default logging message. E.g. "{{res.statusCode}} {{req.method}} {{res.responseTime}}ms {{req.url}}"
//expressFormat: true, // Use the default Express/morgan request formatting. Enabling this will override any msg if true. Will only output colors with colorize set to true
//colorize: true, // Color the text and status code, using the Express/morgan color palette (text: gray, status: default green, 3XX cyan, 4XX yellow, 5XX red).
});
//# sourceMappingURL=logger.js.map