UNPKG

next-logs

Version:

lightning fast, local server and client side logger for NextJS, NodeJS and JS Applications and Servers

75 lines (63 loc) 1.5 kB
var log = function log(message, attributes, type) { if (type === void 0) { type = 'info'; } try { return Promise.resolve(fetch("/api/logger/" + type, { method: 'POST', headers: { Accept: 'application/json', 'Content-Type': 'application/json' }, body: JSON.stringify({ message: message, attributes: attributes }) })).then(function (response) { return Promise.resolve(response.json()); }); } catch (e) { return Promise.reject(e); } }; var clientLog = { log: log, info: function info(message, attributes) { if (message === void 0) { message = ''; } if (attributes === void 0) { attributes = {}; } return log(message, attributes, 'info'); }, debug: function debug(message, attributes) { if (message === void 0) { message = ''; } if (attributes === void 0) { attributes = {}; } return log(message, attributes, 'debug'); }, warn: function warn(message, attributes) { if (message === void 0) { message = ''; } if (attributes === void 0) { attributes = {}; } return log(message, attributes, 'warn'); }, error: function error(message, attributes) { if (message === void 0) { message = ''; } if (attributes === void 0) { attributes = {}; } return log(message, attributes, 'error'); } }; module.exports = clientLog; //# sourceMappingURL=index.modern.js.map