UNPKG

liefern

Version:

Node Webserver without dependencies

31 lines 1.06 kB
export const createLogger = (_name) => { const nowString = () => new Date().toISOString(); const _logger = {}; Object.defineProperty(_logger, 'log', { get: function () { return console.log.bind(console, `[${_name}]`, '[' + nowString() + ']'); }, }); Object.defineProperty(_logger, 'info', { get: function () { return console.info.bind(console, `[${_name}]`, '[' + nowString() + ']'); }, }); Object.defineProperty(_logger, 'debug', { get: function () { return console.debug.bind(console, `[${_name}]`, '[' + nowString() + ']'); }, }); Object.defineProperty(_logger, 'warn', { get: function () { return console.warn.bind(console, `[${_name}]`, '[' + nowString() + ']'); }, }); Object.defineProperty(_logger, 'error', { get: function () { return console.error.bind(console, `[${_name}]`, '[' + nowString() + ']'); }, }); return _logger; }; //# sourceMappingURL=logger.js.map