logger-steps
Version:
Group log messages and send them in one batch to the logger of your choize
2 lines (1 loc) • 953 B
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.loggerSteps=t()}(this,function(){"use strict";var e=["error","warn","log","info","debug"],t=function(t){function n(e){e&&s.warn("Automatic trace flush","This usually means an error on the process using the trace or a bad trace-API usage"),t[i].apply(t,f),clearTimeout(c)}function r(){return c&&clearTimeout(c),c=setTimeout(n,1e3*u,!0)}var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Steps",u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:30;u="number"==typeof u?u:30;var i="debug",a=4,f=[o+": \n"],s={},c=r(),l=function(e,t,n){for(var o=arguments.length,u=Array(o>3?o-3:0),s=3;s<o;s++)u[s-3]=arguments[s];var c={title:n};u.length>0&&(c.details=1===u.length?u[0]:u),f.push(c),t<a&&(a=t,i=e),r()};return s.flush=n.bind(s,!1),e.reduce(function(e,t,n){return e[t]=l.bind(e,t,n),e},s)};return t});