axe 11.2.2 → 11.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -792,15 +792,16 @@ We recommend [superagent](https://github.com/visionmedia/superagent), however th
792
792
  1. You will also need to install additional packages:
793
793
 
794
794
  ```sh
795
- npm install axe fast-safe-stringify cuid superagent
795
+ npm install axe cuid parse-err fast-safe-stringify superagent
796
796
  ```
797
797
 
798
798
  2. Implementation example is provided below (and you can also refer to the [Forward Email][forward-email-code] code base):
799
799
 
800
800
  ```js
801
801
  const Axe = require('axe');
802
- const safeStringify = require('fast-safe-stringify');
803
802
  const cuid = require('cuid');
803
+ const parseErr = require('parse-err');
804
+ const safeStringify = require('fast-safe-stringify');
804
805
  const superagent = require('superagent');
805
806
 
806
807
  const logger = new Axe();
@@ -833,7 +834,7 @@ We recommend [superagent](https://github.com/visionmedia/superagent), however th
833
834
  const response = await request
834
835
  .type('application/json')
835
836
  .retry(3)
836
- .send(safeStringify({ err, message, meta }));
837
+ .send(safeStringify({ err: parseErr(err), message, meta }));
837
838
 
838
839
  logger.info('log sent over HTTP', { response, ignore_hook: true });
839
840
  } catch (err) {
@@ -982,13 +983,14 @@ See below example and the reference at <https://docs.datadoghq.com/logs/log_coll
982
983
  Be sure to replace `DATADOG_API_KEY` and `DATADOG_APP_NAME` with your Datadog API key and application name.
983
984
 
984
985
  ```sh
985
- npm install axe fast-safe-stringify cuid superagent
986
+ npm install axe cuid parse-err fast-safe-stringify superagent
986
987
  ```
987
988
 
988
989
  ```js
989
990
  const Axe = require('axe');
990
- const safeStringify = require('fast-safe-stringify');
991
991
  const cuid = require('cuid');
992
+ const parseErr = require('parse-err');
993
+ const safeStringify = require('fast-safe-stringify');
992
994
  const superagent = require('superagent');
993
995
 
994
996
  const logger = new Axe();
@@ -1023,7 +1025,7 @@ async function hook(err, message, meta) {
1023
1025
  const response = await request
1024
1026
  .type('application/json')
1025
1027
  .retry(3)
1026
- .send(safeStringify({ err, message, meta }));
1028
+ .send(safeStringify({ err: parseErr(err), message, meta }));
1027
1029
 
1028
1030
  logger.info('log sent over HTTP', { response, ignore_hook: true });
1029
1031
  } catch (err) {
@@ -1043,13 +1045,14 @@ See below example and the reference at <https://www.papertrail.com/help/configur
1043
1045
  Be sure to replace `PAPERTRAIL_TOKEN` with your Papertrail token.
1044
1046
 
1045
1047
  ```sh
1046
- npm install axe fast-safe-stringify cuid superagent
1048
+ npm install axe cuid parse-err fast-safe-stringify superagent
1047
1049
  ```
1048
1050
 
1049
1051
  ```js
1050
1052
  const Axe = require('axe');
1051
- const safeStringify = require('fast-safe-stringify');
1052
1053
  const cuid = require('cuid');
1054
+ const parseErr = require('parse-err');
1055
+ const safeStringify = require('fast-safe-stringify');
1053
1056
  const superagent = require('superagent');
1054
1057
 
1055
1058
  const logger = new Axe();
@@ -1083,7 +1086,7 @@ async function hook(err, message, meta) {
1083
1086
  const response = await request
1084
1087
  .type('application/json')
1085
1088
  .retry(3)
1086
- .send(safeStringify({ err, message, meta }));
1089
+ .send(safeStringify({ err: parseErr(err), message, meta }));
1087
1090
 
1088
1091
  logger.info('log sent over HTTP', { response, ignore_hook: true });
1089
1092
  } catch (err) {
package/dist/axe.js CHANGED
@@ -1287,7 +1287,7 @@ module.exports = function unset(obj, prop) {
1287
1287
  module.exports={
1288
1288
  "name": "axe",
1289
1289
  "description": "Axe is a logger-agnostic wrapper that normalizes logs regardless of argument style. Great for large development teams, old and new projects, and works with Pino, Bunyan, Winston, console, and more. It is lightweight, performant, highly-configurable, and automatically adds OS, CPU, and Git information to your logs. It supports hooks (useful for masking sensitive data) and dot-notation remapping, omitting, and picking of log metadata properties. Made for Forward Email, Lad, and Cabin.",
1290
- "version": "11.2.2",
1290
+ "version": "11.2.3",
1291
1291
  "author": "Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com)",
1292
1292
  "browser": {
1293
1293
  "parse-app-info": false
package/dist/axe.min.js CHANGED
@@ -1 +1 @@
1
- !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Axe=e()}}((function(){!function(e){"use strict";e.console||(e.console={});for(var t,r,n=e.console,o=function(){},i=["memory"],c="assert,clear,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profiles,profileEnd,show,table,time,timeEnd,timeline,timelineEnd,timeStamp,trace,warn".split(",");t=i.pop();)n[t]||(n[t]={});for(;r=c.pop();)n[r]||(n[r]=o)}("undefined"==typeof window?this:window);var e={hostname:function(){return"undefined"!=typeof location?location.hostname:""}},t=function(e){var t=Array.prototype.slice.call(arguments,1);return t.length&&(e=e.toString().replace(/(%?)(%([jds]))/g,(function(e,r,n,o){var i=t.shift();switch(o){case"s":i=""+i;break;case"d":i=Number(i);break;case"j":i=JSON.stringify(i)}return r?(t.unshift(i),e):i}))),t.length&&(e=e.toString()+" "+t.join(" ")),""+e.toString().replace(/%{2,2}/g,"%")},r=["%s","%d","%i","%f","%j","%o","%O","%%"],n=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(n=e,"[object Object]"!==Object.prototype.toString.call(n)||!t)return e;var n;const o=Array.isArray(t)?t:String(t).split(r),{length:i}=o;return i<2?e[o[0]]:((e,t,r)=>{for(let n=0;n<r;n++){if(null===e)return;const r=e[t[n]];if(void 0===r)return;e=r}return e})(e,o,i)},o=function(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return e instanceof Error}},i="undefined"!=typeof Symbol&&Symbol,c={},s=Object.prototype.toString;if("function"==typeof i&&"function"==typeof Symbol&&"symbol"==typeof i("foo")&&"symbol"==typeof Symbol("bar")&&function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),r=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(t in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var n=Object.getOwnPropertySymbols(e);if(1!==n.length||n[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var o=Object.getOwnPropertyDescriptor(e,t);if(42!==o.value||!0!==o.enumerable)return!1}return!0}()){var a=Symbol.prototype.toString,f=/^Symbol\(.*\)$/;c=function(e){if("symbol"==typeof e)return!0;if("[object Symbol]"!==s.call(e))return!1;try{return function(e){return"symbol"==typeof e.valueOf()&&f.test(a.call(e))}(e)}catch(t){return!1}}}else c=function(e){return!1};var l=e=>{if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype};const{hasOwnProperty:u}=Object.prototype,{propertyIsEnumerable:p}=Object,g=(e,t,r)=>Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0}),y=this,h={concatArrays:!1,ignoreUndefined:!1},d=e=>{const t=[];for(const r in e)u.call(e,r)&&t.push(r);if(Object.getOwnPropertySymbols){const r=Object.getOwnPropertySymbols(e);for(const n of r)p.call(e,n)&&t.push(n)}return t};function b(e){return Array.isArray(e)?function(e){const t=e.slice(0,0);return d(e).forEach(r=>{g(t,r,b(e[r]))}),t}(e):l(e)?function(e){const t=null===Object.getPrototypeOf(e)?Object.create(null):{};return d(e).forEach(r=>{g(t,r,b(e[r]))}),t}(e):e}const m=(e,t,r,n)=>(r.forEach(r=>{void 0===t[r]&&n.ignoreUndefined||(r in e&&e[r]!==Object.getPrototypeOf(e)?g(e,r,v(e[r],t[r],n)):g(e,r,b(t[r])))}),e);function v(e,t,r){return r.concatArrays&&Array.isArray(e)&&Array.isArray(t)?((e,t,r)=>{let n=e.slice(0,0),o=0;return[e,t].forEach(t=>{const i=[];for(let r=0;r<t.length;r++)u.call(t,r)&&(i.push(String(r)),g(n,o++,t===e?t[r]:b(t[r])));n=m(n,t,d(t).filter(e=>!i.includes(e)),r)}),n})(e,t,r):l(t)&&l(e)?m(e,t,d(t),r):b(t)}var O={};const A=async(e,t)=>{const r=[];let n=0;for(const o of e)r.push(await t(await o,n++));return r};(O=A).default=A;var j={};function w(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return S(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?S(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,c=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return c=e.done,e},e:function(e){s=!0,i=e},f:function(){try{c||null==r.return||r.return()}finally{if(s)throw i}}}}function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var E=function e(t){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!o(t))throw new Error("`err` must be an Error");if(!Array.isArray(r))throw new TypeError("`fields` must be an Array");const n={};var i,c=w(new Set([...Object.getOwnPropertyNames(Object.getPrototypeOf(t)),...Object.getOwnPropertyNames(t)]));try{for(c.s();!(i=c.n()).done;){const e=i.value;"function"!=typeof t[e]&&(n[e]=t[e])}}catch(t){c.e(t)}finally{c.f()}return!n.name&&t.constructor.name&&(n.name=t.constructor.name),Array.isArray(t.errors)&&(n.errors=t.errors.map(t=>o(t)?e(t,r):t)),Array.isArray(r)&&r.length>0?n.filter(e=>r.includes(e)):n};const _=e=>"object"==typeof e||"function"==typeof e,T=(e,t)=>"__proto__"==e||"constructor"==e&&"function"==typeof t.constructor;var P=function(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:".";if(!_(e)||!t||!t.length)return e;const o=Array.isArray(t)?t:String(t).split(n);if(T(o[0],e))return e;const{length:i}=o;return 1===i?(e[o[0]]=r,e):((e,t,r,n)=>{let o=e,i=0;for(;i<r-1;i++){const e=t[i];T(e,o)||(o=_(o[e])?o[e]:o[e]={})}return o[t[i]]=n,e})(e,o,i,r)},k=function(e){return null!=e&&"object"==typeof e&&!1===Array.isArray(e)};function x(e,t,r){return"function"==typeof r.join?r.join(e):e[0]+t+e[1]}function I(e,t,r){return"function"!=typeof r.isValid||r.isValid(e,t)}function L(e){return k(e)||Array.isArray(e)||"function"==typeof e}var M=Object.prototype.toString;function F(e){return"function"==typeof e.constructor?e.constructor.name:null}var N=function e(t){switch(function(e){if(void 0===e)return"undefined";if(null===e)return"null";var t=typeof e;if("boolean"===t)return"boolean";if("string"===t)return"string";if("number"===t)return"number";if("symbol"===t)return"symbol";if("function"===t)return"GeneratorFunction"===F(e)?"generatorfunction":"function";if(function(e){return Array.isArray?Array.isArray(e):e instanceof Array}(e))return"array";if(function(e){return!(!e.constructor||"function"!=typeof e.constructor.isBuffer)&&e.constructor.isBuffer(e)}(e))return"buffer";if(function(e){try{if("number"==typeof e.length&&"function"==typeof e.callee)return!0}catch(t){if(-1!==t.message.indexOf("callee"))return!0}return!1}(e))return"arguments";if(function(e){return e instanceof Date||"function"==typeof e.toDateString&&"function"==typeof e.getDate&&"function"==typeof e.setDate}(e))return"date";if(function(e){return e instanceof Error||"string"==typeof e.message&&e.constructor&&"number"==typeof e.constructor.stackTraceLimit}(e))return"error";if(function(e){return e instanceof RegExp||"string"==typeof e.flags&&"boolean"==typeof e.ignoreCase&&"boolean"==typeof e.multiline&&"boolean"==typeof e.global}(e))return"regexp";switch(F(e)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(function(e){return"function"==typeof e.throw&&"function"==typeof e.return&&"function"==typeof e.next}(e))return"generator";switch(t=M.call(e)){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return t.slice(8,-1).toLowerCase().replace(/\s/g,"")}(t)){case"boolean":case"date":case"function":case"null":case"number":return!0;case"undefined":return!1;case"regexp":return"(?:)"!==t.source&&""!==t.source;case"buffer":return""!==t.toString();case"error":return""!==t.message;case"string":case"arguments":return 0!==t.length;case"file":case"map":case"set":return 0!==t.size;case"array":case"object":for(const r of Object.keys(t))if(e(t[r]))return!0;return!1;default:return!0}},D=function(e,t,r){return!(null==(n=e)||"object"!=typeof n&&"function"!=typeof n&&!Array.isArray(n)||"string"!=typeof t&&!Array.isArray(t))&&N(function(e,t,r){if(k(r)||(r={default:r}),!L(e))return void 0!==r.default?r.default:e;"number"==typeof t&&(t=String(t));const n=Array.isArray(t),o="string"==typeof t,i=r.separator||".",c=r.joinChar||("string"==typeof i?i:".");if(!o&&!n)return e;if(o&&t in e)return I(t,e,r)?e[t]:r.default;let s=n?t:function(e,t,r){return"function"==typeof r.split?r.split(e):e.split(t)}(t,i,r),a=s.length,f=0;do{let t=s[f];for("number"==typeof t&&(t=String(t));t&&"\\"===t.slice(-1);)t=x([t.slice(0,-1),s[++f]||""],c,r);if(t in e){if(!I(t,e,r))return r.default;e=e[t]}else{let n=!1,o=f+1;for(;o<a;)if(n=(t=x([t,s[o++]],c,r))in e){if(!I(t,e,r))return r.default;e=e[t],f=o-1;break}if(!n)return r.default}}while(++f<a&&L(e));return f===a?e:r.default}(e,t,r));var n};const C=e=>{if((e=>"__proto__"===e||"constructor"===e||"prototype"===e)(e))throw new Error(`Cannot set unsafe key: "${e}"`)};var B=function(e,t){if(null==(r=e)||"object"!=typeof r||!1!==Array.isArray(r))throw new TypeError("expected an object.");var r,n=Array.isArray(t);if(!n&&e.hasOwnProperty(t))return delete e[t],!0;if(D(e,t)){for(var o=n?t.slice():t.split("."),i=o.pop();o.length&&"\\"===o[o.length-1].slice(-1);)i=o.pop().slice(0,-1)+"."+i;for(;o.length;)t=o.shift(),C(t),e=e[t];return delete e[i]}return!0},X={};Object.defineProperty(X,"__esModule",{value:!0}),X.boolean=void 0,X.boolean=function(e){switch(Object.prototype.toString.call(e)){case"[object String]":return["true","t","yes","y","on","1"].includes(e.trim().toLowerCase());case"[object Number]":return 1===e.valueOf();case"[object Boolean]":return e.valueOf();default:return!1}};var H={};Object.defineProperty(H,"__esModule",{value:!0}),H.isBooleanable=void 0,H.isBooleanable=function(e){switch(Object.prototype.toString.call(e)){case"[object String]":return["true","t","yes","y","on","1","false","f","no","n","off","0"].includes(e.trim().toLowerCase());case"[object Number]":return[0,1].includes(e.valueOf());case"[object Boolean]":return!0;default:return!1}};var R={};Object.defineProperty(R,"__esModule",{value:!0}),R.boolean=void 0,Object.defineProperty(R,"boolean",{enumerable:!0,get:function(){return X.boolean}}),Object.defineProperty(R,"isBooleanable",{enumerable:!0,get:function(){return H.isBooleanable}});var U,K,W,z="11.2.2",$=U={};function V(){throw new Error("setTimeout has not been defined")}function G(){throw new Error("clearTimeout has not been defined")}function J(e){if(K===setTimeout)return setTimeout(e,0);if((K===V||!K)&&setTimeout)return K=setTimeout,setTimeout(e,0);try{return K(e,0)}catch(t){try{return K.call(null,e,0)}catch(t){return K.call(this,e,0)}}}!function(){try{K="function"==typeof setTimeout?setTimeout:V}catch(e){K=V}try{W="function"==typeof clearTimeout?clearTimeout:G}catch(e){W=G}}();var q,Q=[],Y=!1,Z=-1;function ee(){Y&&q&&(Y=!1,q.length?Q=q.concat(Q):Z=-1,Q.length&&te())}function te(){if(!Y){var e=J(ee);Y=!0;for(var t=Q.length;t;){for(q=Q,Q=[];++Z<t;)q&&q[Z].run();Z=-1,t=Q.length}q=null,Y=!1,function(e){if(W===clearTimeout)return clearTimeout(e);if((W===G||!W)&&clearTimeout)return W=clearTimeout,clearTimeout(e);try{W(e)}catch(t){try{return W.call(null,e)}catch(t){return W.call(this,e)}}}(e)}}function re(e,t){this.fun=e,this.array=t}function ne(){}$.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];Q.push(new re(e,t)),1!==Q.length||Y||J(te)},re.prototype.run=function(){this.fun.apply(null,this.array)},$.title="browser",$.browser=!0,$.env={},$.argv=[],$.version="",$.versions={},$.on=ne,$.addListener=ne,$.once=ne,$.off=ne,$.removeListener=ne,$.removeAllListeners=ne,$.emit=ne,$.prependListener=ne,$.prependOnceListener=ne,$.listeners=function(e){return[]},$.binding=function(e){throw new Error("process.binding is not supported")},$.cwd=function(){return"/"},$.chdir=function(e){throw new Error("process.chdir is not supported")},$.umask=function(){return 0};var oe={};return function(i){(function(){const{boolean:s}=R,a=Symbol.for("axe.silent"),f=new Set(["config","log"]),u=["trace","debug","info","warn","error","fatal"],p={warning:"warn",err:"error"},g="`level` invalid, must be: "+u.join(", "),d=i.env.HOSTNAME||e.hostname();function m(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e||c(e))}function A(e){return null==e||"object"==typeof e&&0===Reflect.ownKeys(e).length||"string"==typeof e&&0===e.trim().length}function w(e){return void 0===e}function S(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function _(e){return"string"==typeof e}oe=class{constructor(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const r={};if(i.env.AXE_REMAPPED_META_FIELDS){const e=i.env.AXE_REMAPPED_META_FIELDS.split(",").map(e=>e.split(":"));for(const[t,n]of e)r[t]=n}let n=i.env.AXE_OMIT_META_FIELDS;"string"==typeof n&&(n=n.split(",").map(e=>e.trim())),Array.isArray(n)||(n=[]);let o=i.env.AXE_PICK_META_FIELDS;"string"==typeof o&&(o=o.split(",").map(e=>e.trim())),Array.isArray(o)||(o=[]),this.config=function(){const e=v(b(h),this!==y&&this||{},h);let t={_:{}};for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];for(const i of n)if(void 0!==i){if(!l(i))throw new TypeError("`"+i+"` is not an Option Object");t=v(t,{_:i},e)}return t._}({showStack:!i.env.AXE_SHOW_STACK||s(i.env.AXE_SHOW_STACK),meta:Object.assign({show:!i.env.AXE_SHOW_META||s(i.env.AXE_SHOW_META),remappedFields:r,omittedFields:n,pickedFields:o,cleanupRemapping:!0,hideHTTP:"is_http",hideMeta:"hide_meta"},"object"==typeof t.meta?t.meta:{}),version:z,silent:!1,logger:console,name:d,level:"info",levels:["info","warn","error","fatal"],appInfo:!i.env.AXE_APP_INFO||s(i.env.AXE_APP_INFO),hooks:Object.assign({pre:[],post:[]},"object"==typeof t.hooks?t.hooks:{})},t),this.appInfo=!!this.config.appInfo&&"function"==typeof j&&j(),this.log=this.log.bind(this);const c=Object.keys(this.config.logger).filter(e=>!f.has(e));for(const i of c)this[i]=this.config.logger[i];for(const i of u)"function"!=typeof this.config.logger[i]&&("fatal"===i?this.config.logger.fatal=this.config.logger.error||this.config.logger.info||this.config.logger.log:this.config.logger[i]=this.config.logger.info||this.config.logger.log),this[i]=function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return e.log(i,...Array.prototype.slice.call(r))};this.setLevel=this.setLevel.bind(this),this.getNormalizedLevel=this.getNormalizedLevel.bind(this),this.setName=this.setName.bind(this),this.config.name&&this.setName(this.config.name),this.setLevel(this.config.level),this.err=this.error,this.warning=this.warn,this.pre=function(e,t){this.config.hooks.pre.push((function(r){for(var n=arguments.length,o=new Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return e!==r?[...o]:t(...o)}))},this.post=function(e,t){this.config.hooks.post.push((function(r){for(var n=arguments.length,o=new Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return e!==r?[...o]:t(...o)}))}}setLevel(e){if(!_(e)||-1===u.indexOf(e))throw new Error(g);_(this.config.logger.logLevel)?this.config.logger.logLevel=e:this.config.logger.level=e,this.config.levels=u.slice(u.indexOf(e))}getNormalizedLevel(e){return _(e)?_(p[e])?p[e]:-1===u.indexOf(e)?"info":e:"info"}setName(e){if(!_(e))throw new Error("`name` must be a String");_(this.config.logger.scope)?this.config.logger.scope=e:this.config.logger.name=e}log(e,i,f){const l=[],g=[];w(e)||l.push(e),w(i)||l.push(i),w(f)||l.push(f);for(var y=arguments.length,h=new Array(y>3?y-3:0),d=3;d<y;d++)h[d-3]=arguments[d];for(const t of Array.prototype.slice.call(h))l.push(t);let b=0;if(_(e)&&_(p[e])?e=p[e]:o(e)?(f=i,i=e,e="error"):_(e)&&-1!==u.indexOf(e)||(f=i,i=e,e=this.getNormalizedLevel(e),b=-1),-1===this.config.levels.indexOf(e))return;let v,j=!1;if((S(i)||Array.isArray(i))&&_(f)){j=!0;const e=f;f=i,i=_(e)&&l.length>=3+b?t(...l.slice(2+b)):e}if(w(i)&&(i=e),1!==l.slice(1+b).length||_(i)||o(i))if(!j&&l.length>=4+b){i=void 0,f={};const r=[];for(const e of l)o(e)?g.push(e):_(e)&&r.push(e);0===g.length&&r.length>0?i=t(...r):g.length>0&&"log"===e&&(e="error")}else if(!j&&l.length===3+b&&_(i)&&r.some(e=>-1!==i.indexOf(e)))i=t(i,f),f={};else if(o(i)){if(o(f)){g.push(f);for(const e of l.slice(2+b))f!==e&&o(e)&&g.push(e);f={}}}else o(f)?(g.push(f),f={}):S(f)||w(f)||null===f?_(i)||(i=t(i)):(i=t(i,f),f={});else f={message:i},i=e;w(f)||S(f)?S(f)||(f={}):f={original_meta:f},o(i)&&(g.unshift(i),i=void 0),S(f.err)&&(o(f.err)&&g.push(f.err),f.original_err=o(f.err)?E(f.err):f.err),g.length>0&&(1===g.length?v=g[0]:((v=new Error([...new Set(g.map(e=>e.message).filter(Boolean))].join("; "))).stack=[...new Set(g.map(e=>e.stack).filter(Boolean))].join("\n\n"),v.errors=g),f.err=E(v),_(i)||(i=v.message)),f.level=e,this.appInfo&&(f.app=this.appInfo);const T=-1===b?"log":e;for(const t of this.config.hooks.pre)[v,i,f]=t(T,v,i,f);const k=s(f[a]);if(!A(this.config.meta.remappedFields))for(const t of Reflect.ownKeys(this.config.meta.remappedFields))if(P(f,this.config.meta.remappedFields[t],n(f,t)),B(f,t),this.config.meta.cleanupRemapping){const e=t.lastIndexOf(".");if(-1===e)continue;const r=t.slice(0,e);A(n(f,r))&&B(f,r)}if(!A(this.config.meta.omittedFields)||!A(this.config.meta.pickedFields)){const e=function(e){const t=[];return function e(r,n){for(const o of Reflect.ownKeys(r)){const i=r[o],c=n?n+"."+o:o;m(i)?e(i,c):t.push(c)}}(e),t}(f);if(!A(this.config.meta.omittedFields))for(const r of this.config.meta.omittedFields){let t=e.length;for(;t--;)(e[t]===r||!c(e[t])&&0===e[t].indexOf(r+"."))&&e.splice(t,1)}const t=[];if(!A(this.config.meta.pickedFields))for(const r of this.config.meta.pickedFields){if(c(r))f[r]&&t.push([r,f[r]]);else{const t=r.indexOf("."),n=r.slice(0,t+1);if(-1!==t){let t=e.length;for(;t--;)c(e[t])||0!==e[t].indexOf(n)||e.splice(t,1)}}-1===e.indexOf(r)&&e.push(r)}for(const r of e)c(r)&&f[r]&&t.push([r,f[r]]);if(f=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(o=e,"[object Object]"!==Object.prototype.toString.call(o)||!t||!Array.isArray(t)&&"string"!=typeof t)return{};var o;const{length:i}=t;if("string"==typeof t||i<2){const o="string"==typeof t?t:t[0],i=n(e,o,r);return void 0!==i?P({},o,i,r):{}}return((e,t,r,o)=>{const i={};for(let c=0;c<r;c++){const r=t[c],s=n(e,r,o);void 0!==s&&P(i,r,s,o)}return i})(e,t,i,r)}(f,e),t.length>0)for(const[r,n]of t)f[r]=n}this.config.silent||k||(o(v)&&this.config.showStack?!this.config.meta.show||A(f)||this.config.meta.hideMeta&&f[this.config.meta.hideMeta]?this.config.logger[T](v):this.config.logger[T](v,f):!this.config.meta.show||A(f)||this.config.meta.hideMeta&&f[this.config.meta.hideMeta]||this.config.meta.hideHTTP&&f[this.config.meta.hideHTTP]?this.config.logger[T](i):this.config.logger[T](i,f)),O(this.config.hooks.post,e=>e(T,v,i,f)).then().catch(e=>{this.config.logger.error(e)})}}}).call(this)}.call(this,U),oe}));
1
+ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Axe=e()}}((function(){!function(e){"use strict";e.console||(e.console={});for(var t,r,n=e.console,o=function(){},i=["memory"],c="assert,clear,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profiles,profileEnd,show,table,time,timeEnd,timeline,timelineEnd,timeStamp,trace,warn".split(",");t=i.pop();)n[t]||(n[t]={});for(;r=c.pop();)n[r]||(n[r]=o)}("undefined"==typeof window?this:window);var e={hostname:function(){return"undefined"!=typeof location?location.hostname:""}},t=function(e){var t=Array.prototype.slice.call(arguments,1);return t.length&&(e=e.toString().replace(/(%?)(%([jds]))/g,(function(e,r,n,o){var i=t.shift();switch(o){case"s":i=""+i;break;case"d":i=Number(i);break;case"j":i=JSON.stringify(i)}return r?(t.unshift(i),e):i}))),t.length&&(e=e.toString()+" "+t.join(" ")),""+e.toString().replace(/%{2,2}/g,"%")},r=["%s","%d","%i","%f","%j","%o","%O","%%"],n=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(n=e,"[object Object]"!==Object.prototype.toString.call(n)||!t)return e;var n;const o=Array.isArray(t)?t:String(t).split(r),{length:i}=o;return i<2?e[o[0]]:((e,t,r)=>{for(let n=0;n<r;n++){if(null===e)return;const r=e[t[n]];if(void 0===r)return;e=r}return e})(e,o,i)},o=function(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return e instanceof Error}},i="undefined"!=typeof Symbol&&Symbol,c={},s=Object.prototype.toString;if("function"==typeof i&&"function"==typeof Symbol&&"symbol"==typeof i("foo")&&"symbol"==typeof Symbol("bar")&&function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),r=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(t in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var n=Object.getOwnPropertySymbols(e);if(1!==n.length||n[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var o=Object.getOwnPropertyDescriptor(e,t);if(42!==o.value||!0!==o.enumerable)return!1}return!0}()){var a=Symbol.prototype.toString,f=/^Symbol\(.*\)$/;c=function(e){if("symbol"==typeof e)return!0;if("[object Symbol]"!==s.call(e))return!1;try{return function(e){return"symbol"==typeof e.valueOf()&&f.test(a.call(e))}(e)}catch(t){return!1}}}else c=function(e){return!1};var l=e=>{if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype};const{hasOwnProperty:u}=Object.prototype,{propertyIsEnumerable:p}=Object,g=(e,t,r)=>Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0}),y=this,h={concatArrays:!1,ignoreUndefined:!1},d=e=>{const t=[];for(const r in e)u.call(e,r)&&t.push(r);if(Object.getOwnPropertySymbols){const r=Object.getOwnPropertySymbols(e);for(const n of r)p.call(e,n)&&t.push(n)}return t};function b(e){return Array.isArray(e)?function(e){const t=e.slice(0,0);return d(e).forEach(r=>{g(t,r,b(e[r]))}),t}(e):l(e)?function(e){const t=null===Object.getPrototypeOf(e)?Object.create(null):{};return d(e).forEach(r=>{g(t,r,b(e[r]))}),t}(e):e}const m=(e,t,r,n)=>(r.forEach(r=>{void 0===t[r]&&n.ignoreUndefined||(r in e&&e[r]!==Object.getPrototypeOf(e)?g(e,r,v(e[r],t[r],n)):g(e,r,b(t[r])))}),e);function v(e,t,r){return r.concatArrays&&Array.isArray(e)&&Array.isArray(t)?((e,t,r)=>{let n=e.slice(0,0),o=0;return[e,t].forEach(t=>{const i=[];for(let r=0;r<t.length;r++)u.call(t,r)&&(i.push(String(r)),g(n,o++,t===e?t[r]:b(t[r])));n=m(n,t,d(t).filter(e=>!i.includes(e)),r)}),n})(e,t,r):l(t)&&l(e)?m(e,t,d(t),r):b(t)}var O={};const A=async(e,t)=>{const r=[];let n=0;for(const o of e)r.push(await t(await o,n++));return r};(O=A).default=A;var j={};function w(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return S(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?S(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,c=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return c=e.done,e},e:function(e){s=!0,i=e},f:function(){try{c||null==r.return||r.return()}finally{if(s)throw i}}}}function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var E=function e(t){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!o(t))throw new Error("`err` must be an Error");if(!Array.isArray(r))throw new TypeError("`fields` must be an Array");const n={};var i,c=w(new Set([...Object.getOwnPropertyNames(Object.getPrototypeOf(t)),...Object.getOwnPropertyNames(t)]));try{for(c.s();!(i=c.n()).done;){const e=i.value;"function"!=typeof t[e]&&(n[e]=t[e])}}catch(t){c.e(t)}finally{c.f()}return!n.name&&t.constructor.name&&(n.name=t.constructor.name),Array.isArray(t.errors)&&(n.errors=t.errors.map(t=>o(t)?e(t,r):t)),Array.isArray(r)&&r.length>0?n.filter(e=>r.includes(e)):n};const _=e=>"object"==typeof e||"function"==typeof e,T=(e,t)=>"__proto__"==e||"constructor"==e&&"function"==typeof t.constructor;var P=function(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:".";if(!_(e)||!t||!t.length)return e;const o=Array.isArray(t)?t:String(t).split(n);if(T(o[0],e))return e;const{length:i}=o;return 1===i?(e[o[0]]=r,e):((e,t,r,n)=>{let o=e,i=0;for(;i<r-1;i++){const e=t[i];T(e,o)||(o=_(o[e])?o[e]:o[e]={})}return o[t[i]]=n,e})(e,o,i,r)},k=function(e){return null!=e&&"object"==typeof e&&!1===Array.isArray(e)};function x(e,t,r){return"function"==typeof r.join?r.join(e):e[0]+t+e[1]}function I(e,t,r){return"function"!=typeof r.isValid||r.isValid(e,t)}function L(e){return k(e)||Array.isArray(e)||"function"==typeof e}var M=Object.prototype.toString;function F(e){return"function"==typeof e.constructor?e.constructor.name:null}var N=function e(t){switch(function(e){if(void 0===e)return"undefined";if(null===e)return"null";var t=typeof e;if("boolean"===t)return"boolean";if("string"===t)return"string";if("number"===t)return"number";if("symbol"===t)return"symbol";if("function"===t)return"GeneratorFunction"===F(e)?"generatorfunction":"function";if(function(e){return Array.isArray?Array.isArray(e):e instanceof Array}(e))return"array";if(function(e){return!(!e.constructor||"function"!=typeof e.constructor.isBuffer)&&e.constructor.isBuffer(e)}(e))return"buffer";if(function(e){try{if("number"==typeof e.length&&"function"==typeof e.callee)return!0}catch(t){if(-1!==t.message.indexOf("callee"))return!0}return!1}(e))return"arguments";if(function(e){return e instanceof Date||"function"==typeof e.toDateString&&"function"==typeof e.getDate&&"function"==typeof e.setDate}(e))return"date";if(function(e){return e instanceof Error||"string"==typeof e.message&&e.constructor&&"number"==typeof e.constructor.stackTraceLimit}(e))return"error";if(function(e){return e instanceof RegExp||"string"==typeof e.flags&&"boolean"==typeof e.ignoreCase&&"boolean"==typeof e.multiline&&"boolean"==typeof e.global}(e))return"regexp";switch(F(e)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(function(e){return"function"==typeof e.throw&&"function"==typeof e.return&&"function"==typeof e.next}(e))return"generator";switch(t=M.call(e)){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return t.slice(8,-1).toLowerCase().replace(/\s/g,"")}(t)){case"boolean":case"date":case"function":case"null":case"number":return!0;case"undefined":return!1;case"regexp":return"(?:)"!==t.source&&""!==t.source;case"buffer":return""!==t.toString();case"error":return""!==t.message;case"string":case"arguments":return 0!==t.length;case"file":case"map":case"set":return 0!==t.size;case"array":case"object":for(const r of Object.keys(t))if(e(t[r]))return!0;return!1;default:return!0}},D=function(e,t,r){return!(null==(n=e)||"object"!=typeof n&&"function"!=typeof n&&!Array.isArray(n)||"string"!=typeof t&&!Array.isArray(t))&&N(function(e,t,r){if(k(r)||(r={default:r}),!L(e))return void 0!==r.default?r.default:e;"number"==typeof t&&(t=String(t));const n=Array.isArray(t),o="string"==typeof t,i=r.separator||".",c=r.joinChar||("string"==typeof i?i:".");if(!o&&!n)return e;if(o&&t in e)return I(t,e,r)?e[t]:r.default;let s=n?t:function(e,t,r){return"function"==typeof r.split?r.split(e):e.split(t)}(t,i,r),a=s.length,f=0;do{let t=s[f];for("number"==typeof t&&(t=String(t));t&&"\\"===t.slice(-1);)t=x([t.slice(0,-1),s[++f]||""],c,r);if(t in e){if(!I(t,e,r))return r.default;e=e[t]}else{let n=!1,o=f+1;for(;o<a;)if(n=(t=x([t,s[o++]],c,r))in e){if(!I(t,e,r))return r.default;e=e[t],f=o-1;break}if(!n)return r.default}}while(++f<a&&L(e));return f===a?e:r.default}(e,t,r));var n};const C=e=>{if((e=>"__proto__"===e||"constructor"===e||"prototype"===e)(e))throw new Error(`Cannot set unsafe key: "${e}"`)};var B=function(e,t){if(null==(r=e)||"object"!=typeof r||!1!==Array.isArray(r))throw new TypeError("expected an object.");var r,n=Array.isArray(t);if(!n&&e.hasOwnProperty(t))return delete e[t],!0;if(D(e,t)){for(var o=n?t.slice():t.split("."),i=o.pop();o.length&&"\\"===o[o.length-1].slice(-1);)i=o.pop().slice(0,-1)+"."+i;for(;o.length;)t=o.shift(),C(t),e=e[t];return delete e[i]}return!0},X={};Object.defineProperty(X,"__esModule",{value:!0}),X.boolean=void 0,X.boolean=function(e){switch(Object.prototype.toString.call(e)){case"[object String]":return["true","t","yes","y","on","1"].includes(e.trim().toLowerCase());case"[object Number]":return 1===e.valueOf();case"[object Boolean]":return e.valueOf();default:return!1}};var H={};Object.defineProperty(H,"__esModule",{value:!0}),H.isBooleanable=void 0,H.isBooleanable=function(e){switch(Object.prototype.toString.call(e)){case"[object String]":return["true","t","yes","y","on","1","false","f","no","n","off","0"].includes(e.trim().toLowerCase());case"[object Number]":return[0,1].includes(e.valueOf());case"[object Boolean]":return!0;default:return!1}};var R={};Object.defineProperty(R,"__esModule",{value:!0}),R.boolean=void 0,Object.defineProperty(R,"boolean",{enumerable:!0,get:function(){return X.boolean}}),Object.defineProperty(R,"isBooleanable",{enumerable:!0,get:function(){return H.isBooleanable}});var U,K,W,z="11.2.3",$=U={};function V(){throw new Error("setTimeout has not been defined")}function G(){throw new Error("clearTimeout has not been defined")}function J(e){if(K===setTimeout)return setTimeout(e,0);if((K===V||!K)&&setTimeout)return K=setTimeout,setTimeout(e,0);try{return K(e,0)}catch(t){try{return K.call(null,e,0)}catch(t){return K.call(this,e,0)}}}!function(){try{K="function"==typeof setTimeout?setTimeout:V}catch(e){K=V}try{W="function"==typeof clearTimeout?clearTimeout:G}catch(e){W=G}}();var q,Q=[],Y=!1,Z=-1;function ee(){Y&&q&&(Y=!1,q.length?Q=q.concat(Q):Z=-1,Q.length&&te())}function te(){if(!Y){var e=J(ee);Y=!0;for(var t=Q.length;t;){for(q=Q,Q=[];++Z<t;)q&&q[Z].run();Z=-1,t=Q.length}q=null,Y=!1,function(e){if(W===clearTimeout)return clearTimeout(e);if((W===G||!W)&&clearTimeout)return W=clearTimeout,clearTimeout(e);try{W(e)}catch(t){try{return W.call(null,e)}catch(t){return W.call(this,e)}}}(e)}}function re(e,t){this.fun=e,this.array=t}function ne(){}$.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];Q.push(new re(e,t)),1!==Q.length||Y||J(te)},re.prototype.run=function(){this.fun.apply(null,this.array)},$.title="browser",$.browser=!0,$.env={},$.argv=[],$.version="",$.versions={},$.on=ne,$.addListener=ne,$.once=ne,$.off=ne,$.removeListener=ne,$.removeAllListeners=ne,$.emit=ne,$.prependListener=ne,$.prependOnceListener=ne,$.listeners=function(e){return[]},$.binding=function(e){throw new Error("process.binding is not supported")},$.cwd=function(){return"/"},$.chdir=function(e){throw new Error("process.chdir is not supported")},$.umask=function(){return 0};var oe={};return function(i){(function(){const{boolean:s}=R,a=Symbol.for("axe.silent"),f=new Set(["config","log"]),u=["trace","debug","info","warn","error","fatal"],p={warning:"warn",err:"error"},g="`level` invalid, must be: "+u.join(", "),d=i.env.HOSTNAME||e.hostname();function m(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e||c(e))}function A(e){return null==e||"object"==typeof e&&0===Reflect.ownKeys(e).length||"string"==typeof e&&0===e.trim().length}function w(e){return void 0===e}function S(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function _(e){return"string"==typeof e}oe=class{constructor(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const r={};if(i.env.AXE_REMAPPED_META_FIELDS){const e=i.env.AXE_REMAPPED_META_FIELDS.split(",").map(e=>e.split(":"));for(const[t,n]of e)r[t]=n}let n=i.env.AXE_OMIT_META_FIELDS;"string"==typeof n&&(n=n.split(",").map(e=>e.trim())),Array.isArray(n)||(n=[]);let o=i.env.AXE_PICK_META_FIELDS;"string"==typeof o&&(o=o.split(",").map(e=>e.trim())),Array.isArray(o)||(o=[]),this.config=function(){const e=v(b(h),this!==y&&this||{},h);let t={_:{}};for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];for(const i of n)if(void 0!==i){if(!l(i))throw new TypeError("`"+i+"` is not an Option Object");t=v(t,{_:i},e)}return t._}({showStack:!i.env.AXE_SHOW_STACK||s(i.env.AXE_SHOW_STACK),meta:Object.assign({show:!i.env.AXE_SHOW_META||s(i.env.AXE_SHOW_META),remappedFields:r,omittedFields:n,pickedFields:o,cleanupRemapping:!0,hideHTTP:"is_http",hideMeta:"hide_meta"},"object"==typeof t.meta?t.meta:{}),version:z,silent:!1,logger:console,name:d,level:"info",levels:["info","warn","error","fatal"],appInfo:!i.env.AXE_APP_INFO||s(i.env.AXE_APP_INFO),hooks:Object.assign({pre:[],post:[]},"object"==typeof t.hooks?t.hooks:{})},t),this.appInfo=!!this.config.appInfo&&"function"==typeof j&&j(),this.log=this.log.bind(this);const c=Object.keys(this.config.logger).filter(e=>!f.has(e));for(const i of c)this[i]=this.config.logger[i];for(const i of u)"function"!=typeof this.config.logger[i]&&("fatal"===i?this.config.logger.fatal=this.config.logger.error||this.config.logger.info||this.config.logger.log:this.config.logger[i]=this.config.logger.info||this.config.logger.log),this[i]=function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return e.log(i,...Array.prototype.slice.call(r))};this.setLevel=this.setLevel.bind(this),this.getNormalizedLevel=this.getNormalizedLevel.bind(this),this.setName=this.setName.bind(this),this.config.name&&this.setName(this.config.name),this.setLevel(this.config.level),this.err=this.error,this.warning=this.warn,this.pre=function(e,t){this.config.hooks.pre.push((function(r){for(var n=arguments.length,o=new Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return e!==r?[...o]:t(...o)}))},this.post=function(e,t){this.config.hooks.post.push((function(r){for(var n=arguments.length,o=new Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return e!==r?[...o]:t(...o)}))}}setLevel(e){if(!_(e)||-1===u.indexOf(e))throw new Error(g);_(this.config.logger.logLevel)?this.config.logger.logLevel=e:this.config.logger.level=e,this.config.levels=u.slice(u.indexOf(e))}getNormalizedLevel(e){return _(e)?_(p[e])?p[e]:-1===u.indexOf(e)?"info":e:"info"}setName(e){if(!_(e))throw new Error("`name` must be a String");_(this.config.logger.scope)?this.config.logger.scope=e:this.config.logger.name=e}log(e,i,f){const l=[],g=[];w(e)||l.push(e),w(i)||l.push(i),w(f)||l.push(f);for(var y=arguments.length,h=new Array(y>3?y-3:0),d=3;d<y;d++)h[d-3]=arguments[d];for(const t of Array.prototype.slice.call(h))l.push(t);let b=0;if(_(e)&&_(p[e])?e=p[e]:o(e)?(f=i,i=e,e="error"):_(e)&&-1!==u.indexOf(e)||(f=i,i=e,e=this.getNormalizedLevel(e),b=-1),-1===this.config.levels.indexOf(e))return;let v,j=!1;if((S(i)||Array.isArray(i))&&_(f)){j=!0;const e=f;f=i,i=_(e)&&l.length>=3+b?t(...l.slice(2+b)):e}if(w(i)&&(i=e),1!==l.slice(1+b).length||_(i)||o(i))if(!j&&l.length>=4+b){i=void 0,f={};const r=[];for(const e of l)o(e)?g.push(e):_(e)&&r.push(e);0===g.length&&r.length>0?i=t(...r):g.length>0&&"log"===e&&(e="error")}else if(!j&&l.length===3+b&&_(i)&&r.some(e=>-1!==i.indexOf(e)))i=t(i,f),f={};else if(o(i)){if(o(f)){g.push(f);for(const e of l.slice(2+b))f!==e&&o(e)&&g.push(e);f={}}}else o(f)?(g.push(f),f={}):S(f)||w(f)||null===f?_(i)||(i=t(i)):(i=t(i,f),f={});else f={message:i},i=e;w(f)||S(f)?S(f)||(f={}):f={original_meta:f},o(i)&&(g.unshift(i),i=void 0),S(f.err)&&(o(f.err)&&g.push(f.err),f.original_err=o(f.err)?E(f.err):f.err),g.length>0&&(1===g.length?v=g[0]:((v=new Error([...new Set(g.map(e=>e.message).filter(Boolean))].join("; "))).stack=[...new Set(g.map(e=>e.stack).filter(Boolean))].join("\n\n"),v.errors=g),f.err=E(v),_(i)||(i=v.message)),f.level=e,this.appInfo&&(f.app=this.appInfo);const T=-1===b?"log":e;for(const t of this.config.hooks.pre)[v,i,f]=t(T,v,i,f);const k=s(f[a]);if(!A(this.config.meta.remappedFields))for(const t of Reflect.ownKeys(this.config.meta.remappedFields))if(P(f,this.config.meta.remappedFields[t],n(f,t)),B(f,t),this.config.meta.cleanupRemapping){const e=t.lastIndexOf(".");if(-1===e)continue;const r=t.slice(0,e);A(n(f,r))&&B(f,r)}if(!A(this.config.meta.omittedFields)||!A(this.config.meta.pickedFields)){const e=function(e){const t=[];return function e(r,n){for(const o of Reflect.ownKeys(r)){const i=r[o],c=n?n+"."+o:o;m(i)?e(i,c):t.push(c)}}(e),t}(f);if(!A(this.config.meta.omittedFields))for(const r of this.config.meta.omittedFields){let t=e.length;for(;t--;)(e[t]===r||!c(e[t])&&0===e[t].indexOf(r+"."))&&e.splice(t,1)}const t=[];if(!A(this.config.meta.pickedFields))for(const r of this.config.meta.pickedFields){if(c(r))f[r]&&t.push([r,f[r]]);else{const t=r.indexOf("."),n=r.slice(0,t+1);if(-1!==t){let t=e.length;for(;t--;)c(e[t])||0!==e[t].indexOf(n)||e.splice(t,1)}}-1===e.indexOf(r)&&e.push(r)}for(const r of e)c(r)&&f[r]&&t.push([r,f[r]]);if(f=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(o=e,"[object Object]"!==Object.prototype.toString.call(o)||!t||!Array.isArray(t)&&"string"!=typeof t)return{};var o;const{length:i}=t;if("string"==typeof t||i<2){const o="string"==typeof t?t:t[0],i=n(e,o,r);return void 0!==i?P({},o,i,r):{}}return((e,t,r,o)=>{const i={};for(let c=0;c<r;c++){const r=t[c],s=n(e,r,o);void 0!==s&&P(i,r,s,o)}return i})(e,t,i,r)}(f,e),t.length>0)for(const[r,n]of t)f[r]=n}this.config.silent||k||(o(v)&&this.config.showStack?!this.config.meta.show||A(f)||this.config.meta.hideMeta&&f[this.config.meta.hideMeta]?this.config.logger[T](v):this.config.logger[T](v,f):!this.config.meta.show||A(f)||this.config.meta.hideMeta&&f[this.config.meta.hideMeta]||this.config.meta.hideHTTP&&f[this.config.meta.hideHTTP]?this.config.logger[T](i):this.config.logger[T](i,f)),O(this.config.hooks.post,e=>e(T,v,i,f)).then().catch(e=>{this.config.logger.error(e)})}}}).call(this)}.call(this,U),oe}));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "axe",
3
3
  "description": "Axe is a logger-agnostic wrapper that normalizes logs regardless of argument style. Great for large development teams, old and new projects, and works with Pino, Bunyan, Winston, console, and more. It is lightweight, performant, highly-configurable, and automatically adds OS, CPU, and Git information to your logs. It supports hooks (useful for masking sensitive data) and dot-notation remapping, omitting, and picking of log metadata properties. Made for Forward Email, Lad, and Cabin.",
4
- "version": "11.2.2",
4
+ "version": "11.2.3",
5
5
  "author": "Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com)",
6
6
  "browser": {
7
7
  "parse-app-info": false