axe 11.0.0 → 11.0.2
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 +126 -2
- package/dist/axe.js +26 -24
- package/dist/axe.min.js +1 -1
- package/lib/index.js +11 -9
- package/package.json +15 -15
package/README.md
CHANGED
|
@@ -35,6 +35,8 @@
|
|
|
35
35
|
* [Send Logs to HTTP Endpoint](#send-logs-to-http-endpoint)
|
|
36
36
|
* [Send Logs to Slack](#send-logs-to-slack)
|
|
37
37
|
* [Send Logs to Sentry](#send-logs-to-sentry)
|
|
38
|
+
* [Send Logs to Datadog](#send-logs-to-datadog)
|
|
39
|
+
* [Send Logs to Papertrail](#send-logs-to-papertrail)
|
|
38
40
|
* [Suppress Logger Data](#suppress-logger-data)
|
|
39
41
|
* [Contributors](#contributors)
|
|
40
42
|
* [License](#license)
|
|
@@ -393,6 +395,7 @@ See [Browser](#browser-1) usage below for more information.
|
|
|
393
395
|
| `meta.omittedFields` | Array | `[]` | Attempts to parse an array value from `process.env.AXE_OMIT_META_FIELDS` (`,` delimited) - meaning you can pass a flag `OMIT_META_FIELDS=user,id node app.js`), determining which fields to omit in the metadata passed to logger methods. Supports dot-notation. | |
|
|
394
396
|
| `meta.pickedFields` | Array | `[]` | Attempts to parse an array value from `process.env.AXE_PICK_META_FIELDS` (`,` delimited) - meaning you can pass a flag, e.g. `PICK_META_FIELDS=request.headers,response.headers node app.js` which would pick from `meta.request` and `meta.response` *only* `meta.request.headers` and `meta.response.headers`), **This takes precedence after fields are omitted, which means this acts as a whitelist.** Supports dot-notation. | |
|
|
395
397
|
| `meta.cleanupRemapping` | Boolean | `true` | Whether or not to cleanup empty objects after remapping operations are completed) | |
|
|
398
|
+
| `meta.hideHTTP` | Boolean | `true` | Whether to suppress HTTP metadata (prevents logger invocation with second arg `meta`) if `meta.is_http` is `true` (via [parse-request][] v5.1.0+). If you manually set `meta.is_http = true` and this is `true`, then `meta` arg will be suppressed as well. | |
|
|
396
399
|
| `silent` | Boolean | `false` | Whether or not to invoke logger methods. Pre and post hooks will still run even if this option is set to `false`. | |
|
|
397
400
|
| `logger` | Object | `console` | Defaults to `console` with [console-polyfill][] added automatically, though **you can bring your own logger**. See [custom logger](#custom-logger) – you can pass an instance of `pino`, `signale`, `winston`, `bunyan`, etc. | |
|
|
398
401
|
| `name` | String or Boolean | `false` if `NODE_ENV` is `"development"` otherwise the value of `process.env.HOSTNAME` or `os.hostname()` | The default name for the logger (defaults to `false` in development environments, which does not set `logger.name`) – this is useful if you are using a logger like `pino` which prefixes log output with the name set here. | |
|
|
@@ -828,9 +831,9 @@ This is an example of using hooks to send a message to Slack with logs of the "f
|
|
|
828
831
|
icon_emoji: ':axe:',
|
|
829
832
|
attachments: [
|
|
830
833
|
{
|
|
831
|
-
title: err && err.message
|
|
834
|
+
title: err && err.message || message,
|
|
832
835
|
color: 'danger',
|
|
833
|
-
text: err && err.stack
|
|
836
|
+
text: err && err.stack || message,
|
|
834
837
|
fields: [
|
|
835
838
|
{
|
|
836
839
|
title: 'Level',
|
|
@@ -907,6 +910,127 @@ for (const level of logger.config.levels) {
|
|
|
907
910
|
logger.error(new Error('uh oh'));
|
|
908
911
|
```
|
|
909
912
|
|
|
913
|
+
### Send Logs to Datadog
|
|
914
|
+
|
|
915
|
+
See below example and the reference at <https://docs.datadoghq.com/logs/log_collection/nodejs/?tab=winston30#agentless-logging>.
|
|
916
|
+
|
|
917
|
+
Be sure to replace `DATADOG_API_KEY` and `DATADOG_APP_NAME` with your Datadog API key and application name.
|
|
918
|
+
|
|
919
|
+
```sh
|
|
920
|
+
npm install axe fast-safe-stringify cuid superagent
|
|
921
|
+
```
|
|
922
|
+
|
|
923
|
+
```js
|
|
924
|
+
const Axe = require('axe');
|
|
925
|
+
const safeStringify = require('fast-safe-stringify');
|
|
926
|
+
const cuid = require('cuid');
|
|
927
|
+
const superagent = require('superagent');
|
|
928
|
+
|
|
929
|
+
const logger = new Axe();
|
|
930
|
+
|
|
931
|
+
// TODO: use env var or replace this const with a string
|
|
932
|
+
const DATADOG_API_KEY = process.env.DATADOG_API_KEY;
|
|
933
|
+
|
|
934
|
+
// TODO: use env var or replace this const with a string
|
|
935
|
+
const DATADOG_APP_NAME = process.env.DATADOG_APP_NAME;
|
|
936
|
+
|
|
937
|
+
// <https://github.com/cabinjs/axe/#send-logs-to-datadog>
|
|
938
|
+
async function hook(err, message, meta) {
|
|
939
|
+
//
|
|
940
|
+
// return early if we wish to ignore this
|
|
941
|
+
// (this prevents recursion; see end of this fn)
|
|
942
|
+
//
|
|
943
|
+
if (meta.ignore_hook) return;
|
|
944
|
+
|
|
945
|
+
try {
|
|
946
|
+
const request = superagent
|
|
947
|
+
.post(`https://http-intake.logs.datadoghq.com/api/v2/logs?dd-api-key=${DATADOG_API_KEY}&ddsource=nodejs&service=${DATADOG_APP_NAME}`)
|
|
948
|
+
// if the meta object already contained a request ID then re-use it
|
|
949
|
+
// otherwise generate one that gets re-used in the API log request
|
|
950
|
+
// (which normalizes server/browser request id formatting)
|
|
951
|
+
.set(
|
|
952
|
+
'X-Request-Id',
|
|
953
|
+
meta && meta.request && meta.request.id ? meta.request.id : cuid()
|
|
954
|
+
)
|
|
955
|
+
.set('X-Axe-Version', logger.config.version)
|
|
956
|
+
.timeout(5000);
|
|
957
|
+
|
|
958
|
+
const response = await request
|
|
959
|
+
.type('application/json')
|
|
960
|
+
.retry(3)
|
|
961
|
+
.send(safeStringify({ err, message, meta }));
|
|
962
|
+
|
|
963
|
+
logger.info('log sent over HTTP', { response, ignore_hook: true });
|
|
964
|
+
} catch (err) {
|
|
965
|
+
logger.fatal(err, { ignore_hook: true });
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
for (const level of logger.config.levels) {
|
|
970
|
+
logger.post(level, hook);
|
|
971
|
+
}
|
|
972
|
+
```
|
|
973
|
+
|
|
974
|
+
### Send Logs to Papertrail
|
|
975
|
+
|
|
976
|
+
See below example and the reference at <https://www.papertrail.com/help/configuring-centralized-logging-from-nodejs-apps/>.
|
|
977
|
+
|
|
978
|
+
Be sure to replace `PAPERTRAIL_TOKEN` with your Papertrail token.
|
|
979
|
+
|
|
980
|
+
```sh
|
|
981
|
+
npm install axe fast-safe-stringify cuid superagent
|
|
982
|
+
```
|
|
983
|
+
|
|
984
|
+
```js
|
|
985
|
+
const Axe = require('axe');
|
|
986
|
+
const safeStringify = require('fast-safe-stringify');
|
|
987
|
+
const cuid = require('cuid');
|
|
988
|
+
const superagent = require('superagent');
|
|
989
|
+
|
|
990
|
+
const logger = new Axe();
|
|
991
|
+
|
|
992
|
+
// TODO: use env var or replace this const with a string
|
|
993
|
+
const PAPERTRAIL_TOKEN = process.env.PAPERTRAIL_TOKEN;
|
|
994
|
+
|
|
995
|
+
// <https://github.com/cabinjs/axe/#send-logs-to-papertrail>
|
|
996
|
+
async function hook(err, message, meta) {
|
|
997
|
+
//
|
|
998
|
+
// return early if we wish to ignore this
|
|
999
|
+
// (this prevents recursion; see end of this fn)
|
|
1000
|
+
//
|
|
1001
|
+
if (meta.ignore_hook) return;
|
|
1002
|
+
|
|
1003
|
+
try {
|
|
1004
|
+
const request = superagent
|
|
1005
|
+
.post('https://logs.collector.solarwinds.com/v1/log')
|
|
1006
|
+
// if the meta object already contained a request ID then re-use it
|
|
1007
|
+
// otherwise generate one that gets re-used in the API log request
|
|
1008
|
+
// (which normalizes server/browser request id formatting)
|
|
1009
|
+
.set(
|
|
1010
|
+
'X-Request-Id',
|
|
1011
|
+
meta && meta.request && meta.request.id ? meta.request.id : cuid()
|
|
1012
|
+
)
|
|
1013
|
+
.set('X-Axe-Version', logger.config.version)
|
|
1014
|
+
.timeout(5000);
|
|
1015
|
+
|
|
1016
|
+
request.auth('', PAPERTRAIL_TOKEN);
|
|
1017
|
+
|
|
1018
|
+
const response = await request
|
|
1019
|
+
.type('application/json')
|
|
1020
|
+
.retry(3)
|
|
1021
|
+
.send(safeStringify({ err, message, meta }));
|
|
1022
|
+
|
|
1023
|
+
logger.info('log sent over HTTP', { response, ignore_hook: true });
|
|
1024
|
+
} catch (err) {
|
|
1025
|
+
logger.fatal(err, { ignore_hook: true });
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
for (const level of logger.config.levels) {
|
|
1030
|
+
logger.post(level, hook);
|
|
1031
|
+
}
|
|
1032
|
+
```
|
|
1033
|
+
|
|
910
1034
|
### Suppress Logger Data
|
|
911
1035
|
|
|
912
1036
|
This is an example of using a custom hook to manipulate logger arguments to suppress sensitive data.
|
package/dist/axe.js
CHANGED
|
@@ -1128,7 +1128,7 @@ module.exports = function unset(obj, prop) {
|
|
|
1128
1128
|
module.exports={
|
|
1129
1129
|
"name": "axe",
|
|
1130
1130
|
"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.",
|
|
1131
|
-
"version": "11.0.
|
|
1131
|
+
"version": "11.0.2",
|
|
1132
1132
|
"author": "Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com)",
|
|
1133
1133
|
"browser": {
|
|
1134
1134
|
"parse-app-info": false
|
|
@@ -1159,36 +1159,36 @@ module.exports={
|
|
|
1159
1159
|
"unset-value": "2.0.1"
|
|
1160
1160
|
},
|
|
1161
1161
|
"devDependencies": {
|
|
1162
|
-
"@babel/cli": "^7.
|
|
1163
|
-
"@babel/core": "^7.
|
|
1164
|
-
"@babel/preset-env": "^7.
|
|
1165
|
-
"@commitlint/cli": "^17.0
|
|
1166
|
-
"@commitlint/config-conventional": "^17.0
|
|
1167
|
-
"ava": "^
|
|
1162
|
+
"@babel/cli": "^7.19.3",
|
|
1163
|
+
"@babel/core": "^7.20.2",
|
|
1164
|
+
"@babel/preset-env": "^7.20.2",
|
|
1165
|
+
"@commitlint/cli": "^17.3.0",
|
|
1166
|
+
"@commitlint/config-conventional": "^17.3.0",
|
|
1167
|
+
"ava": "^5.1.0",
|
|
1168
1168
|
"babelify": "^10.0.0",
|
|
1169
1169
|
"browserify": "^17.0.0",
|
|
1170
1170
|
"consola": "^2.15.3",
|
|
1171
1171
|
"cross-env": "^7.0.3",
|
|
1172
|
-
"eslint": "^8.
|
|
1172
|
+
"eslint": "^8.28.0",
|
|
1173
1173
|
"eslint-config-xo-lass": "^2.0.1",
|
|
1174
1174
|
"eslint-plugin-compat": "^4.0.2",
|
|
1175
1175
|
"eslint-plugin-node": "^11.1.0",
|
|
1176
|
-
"express": "^4.18.
|
|
1176
|
+
"express": "^4.18.2",
|
|
1177
1177
|
"fixpack": "^4.0.0",
|
|
1178
|
-
"husky": "^8.0.
|
|
1178
|
+
"husky": "^8.0.2",
|
|
1179
1179
|
"jsdom": "15.x",
|
|
1180
1180
|
"koa": "^2.13.4",
|
|
1181
|
-
"lint-staged": "^13.0.
|
|
1181
|
+
"lint-staged": "^13.0.4",
|
|
1182
1182
|
"lodash": "^4.17.21",
|
|
1183
1183
|
"nyc": "^15.1.0",
|
|
1184
|
-
"pino": "^8.
|
|
1185
|
-
"remark-cli": "^
|
|
1184
|
+
"pino": "^8.7.0",
|
|
1185
|
+
"remark-cli": "^11.0.0",
|
|
1186
1186
|
"remark-preset-github": "^4.0.4",
|
|
1187
1187
|
"rimraf": "^3.0.2",
|
|
1188
1188
|
"signale": "^1.4.0",
|
|
1189
|
-
"sinon": "^14.0.
|
|
1189
|
+
"sinon": "^14.0.2",
|
|
1190
1190
|
"tinyify": "3.0.0",
|
|
1191
|
-
"xo": "^0.
|
|
1191
|
+
"xo": "^0.53.1"
|
|
1192
1192
|
},
|
|
1193
1193
|
"engines": {
|
|
1194
1194
|
"node": ">=14"
|
|
@@ -1265,6 +1265,8 @@ module.exports={
|
|
|
1265
1265
|
(function (process){(function (){
|
|
1266
1266
|
// eslint-disable-next-line import/no-unassigned-import
|
|
1267
1267
|
require('console-polyfill');
|
|
1268
|
+
|
|
1269
|
+
// eslint-disable-next-line unicorn/prefer-node-protocol
|
|
1268
1270
|
const os = require('os');
|
|
1269
1271
|
const combine = require('maybe-combine-errors');
|
|
1270
1272
|
const format = require('@ladjs/format-util');
|
|
@@ -1356,7 +1358,8 @@ class Axe {
|
|
|
1356
1358
|
remappedFields,
|
|
1357
1359
|
omittedFields: process.env.AXE_OMIT_META_FIELDS ? process.env.AXE_OMIT_META_FIELDS.split(',').map(s => s.trim()) : [],
|
|
1358
1360
|
pickedFields: process.env.AXE_PICK_META_FIELDS ? process.env.AXE_PICK_META_FIELDS.split(',').map(s => s.trim()) : [],
|
|
1359
|
-
cleanupRemapping: true
|
|
1361
|
+
cleanupRemapping: true,
|
|
1362
|
+
hideHTTP: true
|
|
1360
1363
|
}, typeof config.meta === 'object' ? config.meta : {}),
|
|
1361
1364
|
version: pkg.version,
|
|
1362
1365
|
silent: false,
|
|
@@ -1465,9 +1468,6 @@ class Axe {
|
|
|
1465
1468
|
for (const arg of Array.prototype.slice.call(args)) {
|
|
1466
1469
|
originalArgs.push(arg);
|
|
1467
1470
|
}
|
|
1468
|
-
const {
|
|
1469
|
-
config
|
|
1470
|
-
} = this;
|
|
1471
1471
|
let modifier = 0;
|
|
1472
1472
|
if (isString(level) && isString(aliases[level])) {
|
|
1473
1473
|
level = aliases[level];
|
|
@@ -1483,7 +1483,7 @@ class Axe {
|
|
|
1483
1483
|
}
|
|
1484
1484
|
|
|
1485
1485
|
// Return early if it is not a valid logging level
|
|
1486
|
-
if (config.levels.indexOf(level) === -1) return;
|
|
1486
|
+
if (this.config.levels.indexOf(level) === -1) return;
|
|
1487
1487
|
|
|
1488
1488
|
// Bunyan support (meta, message, ...args)
|
|
1489
1489
|
let isBunyan = false;
|
|
@@ -1672,15 +1672,17 @@ class Axe {
|
|
|
1672
1672
|
}
|
|
1673
1673
|
|
|
1674
1674
|
// only invoke logger methods if it was not silent
|
|
1675
|
-
if (!config.silent) {
|
|
1675
|
+
if (!this.config.silent) {
|
|
1676
1676
|
// Show stack trace if necessary (along with any metadata)
|
|
1677
|
-
if (isError(err) && config.showStack) {
|
|
1678
|
-
if (!config.meta.show || isEmpty(meta)) {
|
|
1677
|
+
if (isError(err) && this.config.showStack) {
|
|
1678
|
+
if (!this.config.meta.show || isEmpty(meta)) {
|
|
1679
1679
|
this.config.logger[method](err);
|
|
1680
1680
|
} else {
|
|
1681
1681
|
this.config.logger[method](err, meta);
|
|
1682
1682
|
}
|
|
1683
|
-
} else if (!config.meta.show || isEmpty(meta)) {
|
|
1683
|
+
} else if (!this.config.meta.show || isEmpty(meta)) {
|
|
1684
|
+
this.config.logger[method](message);
|
|
1685
|
+
} else if (meta.is_http && this.config.meta.hideHTTP) {
|
|
1684
1686
|
this.config.logger[method](message);
|
|
1685
1687
|
} else {
|
|
1686
1688
|
this.config.logger[method](message, meta);
|
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"],s="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=s.pop();)n[r]||(n[r]=o)}("undefined"==typeof window?this:window);var e={hostname:function(){return"undefined"!=typeof location?location.hostname:""}};const t=Symbol("kErrors");class r extends Error{constructor(e){const r=new Set(e.map(s).filter(Boolean));super(Array.from(r).join("; ")),n(this,"name","CombinedError"),n(this,t,e),o(this,"stack",()=>e.map(c).join("\n\n")),o(this,"transient",()=>e.length>0&&e.every(a)),o(this,"expected",()=>e.length>0&&e.every(f))}[Symbol.iterator](){return this[t][Symbol.iterator]()}}function n(e,t,r){Object.defineProperty(e,t,{value:r})}function o(e,t,r){Object.defineProperty(e,t,{get:r})}function i(e){return null!=e}function s(e){return e.message}function c(e){return e.stack}function a(e){return!0===e.transient}function f(e){return!0===e.expected}var u=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,"%")},l=["%s","%d","%i","%f","%j","%o","%O","%%"],p=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)},g=function(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return e instanceof Error}},h=e=>{if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype};const{hasOwnProperty:y}=Object.prototype,{propertyIsEnumerable:d}=Object,m=(e,t,r)=>Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0}),b=this,v={concatArrays:!1,ignoreUndefined:!1},A=e=>{const t=[];for(const r in e)y.call(e,r)&&t.push(r);if(Object.getOwnPropertySymbols){const r=Object.getOwnPropertySymbols(e);for(const n of r)d.call(e,n)&&t.push(n)}return t};function O(e){return Array.isArray(e)?function(e){const t=e.slice(0,0);return A(e).forEach(r=>{m(t,r,O(e[r]))}),t}(e):h(e)?function(e){const t=null===Object.getPrototypeOf(e)?Object.create(null):{};return A(e).forEach(r=>{m(t,r,O(e[r]))}),t}(e):e}const j=(e,t,r,n)=>(r.forEach(r=>{void 0===t[r]&&n.ignoreUndefined||(r in e&&e[r]!==Object.getPrototypeOf(e)?m(e,r,w(e[r],t[r],n)):m(e,r,O(t[r])))}),e);function w(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++)y.call(t,r)&&(i.push(String(r)),m(n,o++,t===e?t[r]:O(t[r])));n=j(n,t,A(t).filter(e=>!i.includes(e)),r)}),n})(e,t,r):h(t)&&h(e)?j(e,t,A(t),r):O(t)}var E={};const S=async(e,t)=>{const r=[];let n=0;for(const o of e)r.push(await t(await o,n++));return r};(E=S).default=S;var _={},T=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!g(e))throw new Error("`err` must be an Error");if(!Array.isArray(t))throw new Error("`fields` must be an Array");var r={};return Object.getOwnPropertyNames(Object.getPrototypeOf(e)).concat(Object.getOwnPropertyNames(e)).forEach((function(t){"function"!=typeof e[t]&&(r[t]=e[t])})),!r.name&&e.constructor.name&&(r.name=e.constructor.name),Array.isArray(t)&&0!==t.length?r.filter((function(e){return t.includes(e)})):r};const k=e=>"object"==typeof e||"function"==typeof e,P=(e,t)=>"__proto__"==e||"constructor"==e&&"function"==typeof t.constructor;var x=function(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:".";if(!k(e)||!t||!t.length)return e;const o=Array.isArray(t)?t:String(t).split(n);if(P(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];P(e,o)||(o=k(o[e])?o[e]:o[e]={})}return o[t[i]]=n,e})(e,o,i,r)},I=function(e){return null!=e&&"object"==typeof e&&!1===Array.isArray(e)};function L(e,t,r){return"function"==typeof r.join?r.join(e):e[0]+t+e[1]}function F(e,t,r){return"function"!=typeof r.isValid||r.isValid(e,t)}function M(e){return I(e)||Array.isArray(e)||"function"==typeof e}var N=Object.prototype.toString;function C(e){return"function"==typeof e.constructor?e.constructor.name:null}var D=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"===C(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(C(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=N.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}},X=function(e,t,r){return!(null==(n=e)||"object"!=typeof n&&"function"!=typeof n&&!Array.isArray(n)||"string"!=typeof t&&!Array.isArray(t))&&D(function(e,t,r){if(I(r)||(r={default:r}),!M(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||".",s=r.joinChar||("string"==typeof i?i:".");if(!o&&!n)return e;if(o&&t in e)return F(t,e,r)?e[t]:r.default;let c=n?t:function(e,t,r){return"function"==typeof r.split?r.split(e):e.split(t)}(t,i,r),a=c.length,f=0;do{let t=c[f];for("number"==typeof t&&(t=String(t));t&&"\\"===t.slice(-1);)t=L([t.slice(0,-1),c[++f]||""],s,r);if(t in e){if(!F(t,e,r))return r.default;e=e[t]}else{let n=!1,o=f+1;for(;o<a;)if(n=(t=L([t,c[o++]],s,r))in e){if(!F(t,e,r))return r.default;e=e[t],f=o-1;break}if(!n)return r.default}}while(++f<a&&M(e));return f===a?e:r.default}(e,t,r));var n};const B=e=>{if((e=>"__proto__"===e||"constructor"===e||"prototype"===e)(e))throw new Error(`Cannot set unsafe key: "${e}"`)};var U=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(X(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(),B(t),e=e[t];return delete e[i]}return!0},W={};Object.defineProperty(W,"__esModule",{value:!0}),W.boolean=void 0,W.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 z={};Object.defineProperty(z,"__esModule",{value:!0}),z.isBooleanable=void 0,z.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 H={};Object.defineProperty(H,"__esModule",{value:!0}),H.boolean=void 0,Object.defineProperty(H,"boolean",{enumerable:!0,get:function(){return W.boolean}}),Object.defineProperty(H,"isBooleanable",{enumerable:!0,get:function(){return z.isBooleanable}});var R,K,V,G="11.0.0",J=R={};function $(){throw new Error("setTimeout has not been defined")}function q(){throw new Error("clearTimeout has not been defined")}function Q(e){if(K===setTimeout)return setTimeout(e,0);if((K===$||!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:$}catch(e){K=$}try{V="function"==typeof clearTimeout?clearTimeout:q}catch(e){V=q}}();var Y,Z=[],ee=!1,te=-1;function re(){ee&&Y&&(ee=!1,Y.length?Z=Y.concat(Z):te=-1,Z.length&&ne())}function ne(){if(!ee){var e=Q(re);ee=!0;for(var t=Z.length;t;){for(Y=Z,Z=[];++te<t;)Y&&Y[te].run();te=-1,t=Z.length}Y=null,ee=!1,function(e){if(V===clearTimeout)return clearTimeout(e);if((V===q||!V)&&clearTimeout)return V=clearTimeout,clearTimeout(e);try{V(e)}catch(t){try{return V.call(null,e)}catch(t){return V.call(this,e)}}}(e)}}function oe(e,t){this.fun=e,this.array=t}function ie(){}J.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];Z.push(new oe(e,t)),1!==Z.length||ee||Q(ne)},oe.prototype.run=function(){this.fun.apply(null,this.array)},J.title="browser",J.browser=!0,J.env={},J.argv=[],J.version="",J.versions={},J.on=ie,J.addListener=ie,J.once=ie,J.off=ie,J.removeListener=ie,J.removeAllListeners=ie,J.emit=ie,J.prependListener=ie,J.prependOnceListener=ie,J.listeners=function(e){return[]},J.binding=function(e){throw new Error("process.binding is not supported")},J.cwd=function(){return"/"},J.chdir=function(e){throw new Error("process.chdir is not supported")},J.umask=function(){return 0};var se={};return function(t){(function(){const{boolean:n}=H,o=new Set(["config","log"]),s=["trace","debug","info","warn","error","fatal"],c={warning:"warn",err:"error"},a="`level` invalid, must be: "+s.join(", "),f=t.env.HOSTNAME||e.hostname();function y(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)}function d(e){return null==e||"object"==typeof e&&0===Object.keys(e).length||"string"==typeof e&&0===e.trim().length}function m(e){return void 0===e}function A(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function j(e){return"string"==typeof e}se=class{constructor(){var e=this;let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const i={};if(t.env.AXE_REMAPPED_META_FIELDS){const e=t.env.AXE_REMAPPED_META_FIELDS.split(",").map(e=>e.split(":"));for(const[t,r]of e)i[t]=r}this.config=function(){const e=w(O(v),this!==b&&this||{},v);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(!h(i))throw new TypeError("`"+i+"` is not an Option Object");t=w(t,{_:i},e)}return t._}({showStack:!t.env.AXE_SHOW_STACK||n(t.env.AXE_SHOW_STACK),meta:Object.assign({show:!t.env.AXE_SHOW_META||n(t.env.AXE_SHOW_META),remappedFields:i,omittedFields:t.env.AXE_OMIT_META_FIELDS?t.env.AXE_OMIT_META_FIELDS.split(",").map(e=>e.trim()):[],pickedFields:t.env.AXE_PICK_META_FIELDS?t.env.AXE_PICK_META_FIELDS.split(",").map(e=>e.trim()):[],cleanupRemapping:!0},"object"==typeof r.meta?r.meta:{}),version:G,silent:!1,logger:console,name:f,level:"info",levels:["info","warn","error","fatal"],appInfo:!t.env.AXE_APP_INFO||n(t.env.AXE_APP_INFO),hooks:Object.assign({pre:[],post:[]},"object"==typeof r.hooks?r.hooks:{})},r),this.appInfo=!!this.config.appInfo&&"function"==typeof _&&_(),this.log=this.log.bind(this);const c=Object.keys(this.config.logger).filter(e=>!o.has(e));for(const t of c)this[t]=this.config.logger[t];for(const t of s)"function"!=typeof this.config.logger[t]&&("fatal"===t?this.config.logger.fatal=this.config.logger.error||this.config.logger.info||this.config.logger.log:this.config.logger[t]=this.config.logger.info||this.config.logger.log),this[t]=function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return e.log(t,...Array.prototype.slice.call(n))};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(!j(e)||-1===s.indexOf(e))throw new Error(a);j(this.config.logger.logLevel)?this.config.logger.logLevel=e:this.config.logger.level=e,this.config.levels=s.slice(s.indexOf(e))}getNormalizedLevel(e){return j(e)?j(c[e])?c[e]:-1===s.indexOf(e)?"info":e:"info"}setName(e){if(!j(e))throw new Error("`name` must be a String");j(this.config.logger.scope)?this.config.logger.scope=e:this.config.logger.name=e}log(e,t,n){const o=[],a=[];m(e)||o.push(e),m(t)||o.push(t),m(n)||o.push(n);for(var f=arguments.length,h=new Array(f>3?f-3:0),b=3;b<f;b++)h[b-3]=arguments[b];for(const r of Array.prototype.slice.call(h))o.push(r);const{config:v}=this;let O=0;if(j(e)&&j(c[e])?e=c[e]:g(e)?(n=t,t=e,e="error"):j(e)&&-1!==s.indexOf(e)||(n=t,t=e,e=this.getNormalizedLevel(e),O=-1),-1===v.levels.indexOf(e))return;let w,S=!1;if((A(t)||Array.isArray(t))&&j(n)){S=!0;const e=n;n=t,t=j(e)&&o.length>=3+O?u(...o.slice(2+O)):e}if(m(t)&&(t=e),1!==o.slice(1+O).length||j(t)||g(t))if(!S&&o.length>=4+O){t=void 0,n={};const r=[];for(const e of o)g(e)?a.push(e):j(e)&&r.push(e);0===a.length&&r.length>0?t=u(...r):a.length>0&&"log"===e&&(e="error")}else if(!S&&o.length===3+O&&j(t)&&l.some(e=>-1!==t.indexOf(e)))t=u(t,n),n={};else if(g(t)){if(g(n)){a.push(n);for(const e of o.slice(2+O))n!==e&&g(e)&&a.push(e);n={}}}else g(n)?(a.push(n),n={}):A(n)||m(n)||null===n?j(t)||(t=u(t)):(t=u(t,n),n={});else n={message:t},t=e;m(n)||A(n)?A(n)||(n={}):n={original_meta:n},g(t)&&(a.unshift(t),t=void 0),A(n.err)&&(g(n.err)&&a.push(n.err),n.original_err=g(n.err)?T(n.err):n.err),a.length>0&&(w=function(e){if(0!==(e=e.filter(i)).length)return 1===e.length?e[0]:new r(e)}(a),n.err=T(w),j(t)||(t=w.message)),n.level=e,this.appInfo&&(n.app=this.appInfo);const _=-1===O?"log":e;for(const r of this.config.hooks.pre)[w,t,n]=r(_,w,t,n);if(!d(this.config.meta.remappedFields))for(const r of Object.keys(this.config.meta.remappedFields))if(x(n,this.config.meta.remappedFields[r],p(n,r)),U(n,r),this.config.meta.cleanupRemapping){const e=r.lastIndexOf(".");if(-1===e)continue;const t=r.slice(0,e);d(p(n,t))&&U(n,t)}if(!d(this.config.meta.omittedFields)||!d(this.config.meta.pickedFields)){const e=function(e){const t=[];return function e(r,n){for(const o of Object.keys(r)){const i=r[o],s=n?n+"."+o:o;y(i)?e(i,s):t.push(s)}}(e),t}(n);if(!d(this.config.meta.omittedFields))for(const t of this.config.meta.omittedFields){let r=e.length;for(;r--;)e[r]!==t&&0!==e[r].indexOf(t+".")||e.splice(r,1)}if(!d(this.config.meta.pickedFields))for(const t of this.config.meta.pickedFields){const r=t.indexOf("."),n=t.slice(0,r+1);if(-1!==r){let t=e.length;for(;t--;)0===e[t].indexOf(n)&&e.splice(t,1)}-1===e.indexOf(t)&&e.push(t)}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||!Array.isArray(t)&&"string"!=typeof t)return{};var n;const{length:o}=t;if("string"==typeof t||o<2){const n="string"==typeof t?t:t[0],o=p(e,n,r);return void 0!==o?x({},n,o,r):{}}return((e,t,r,n)=>{const o={};for(let i=0;i<r;i++){const r=t[i],s=p(e,r,n);void 0!==s&&x(o,r,s,n)}return o})(e,t,o,r)}(n,e)}v.silent||(g(w)&&v.showStack?!v.meta.show||d(n)?this.config.logger[_](w):this.config.logger[_](w,n):!v.meta.show||d(n)?this.config.logger[_](t):this.config.logger[_](t,n)),E(this.config.hooks.post,e=>e(_,w,t,n)).then().catch(e=>{this.config.logger.error(e)})}}}).call(this)}.call(this,R),se}));
|
|
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"],s="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=s.pop();)n[r]||(n[r]=o)}("undefined"==typeof window?this:window);var e={hostname:function(){return"undefined"!=typeof location?location.hostname:""}};const t=Symbol("kErrors");class r extends Error{constructor(e){const r=new Set(e.map(s).filter(Boolean));super(Array.from(r).join("; ")),n(this,"name","CombinedError"),n(this,t,e),o(this,"stack",()=>e.map(c).join("\n\n")),o(this,"transient",()=>e.length>0&&e.every(a)),o(this,"expected",()=>e.length>0&&e.every(f))}[Symbol.iterator](){return this[t][Symbol.iterator]()}}function n(e,t,r){Object.defineProperty(e,t,{value:r})}function o(e,t,r){Object.defineProperty(e,t,{get:r})}function i(e){return null!=e}function s(e){return e.message}function c(e){return e.stack}function a(e){return!0===e.transient}function f(e){return!0===e.expected}var u=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,"%")},l=["%s","%d","%i","%f","%j","%o","%O","%%"],g=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)},p=function(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return e instanceof Error}},h=e=>{if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype};const{hasOwnProperty:y}=Object.prototype,{propertyIsEnumerable:d}=Object,m=(e,t,r)=>Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0}),b=this,v={concatArrays:!1,ignoreUndefined:!1},A=e=>{const t=[];for(const r in e)y.call(e,r)&&t.push(r);if(Object.getOwnPropertySymbols){const r=Object.getOwnPropertySymbols(e);for(const n of r)d.call(e,n)&&t.push(n)}return t};function O(e){return Array.isArray(e)?function(e){const t=e.slice(0,0);return A(e).forEach(r=>{m(t,r,O(e[r]))}),t}(e):h(e)?function(e){const t=null===Object.getPrototypeOf(e)?Object.create(null):{};return A(e).forEach(r=>{m(t,r,O(e[r]))}),t}(e):e}const j=(e,t,r,n)=>(r.forEach(r=>{void 0===t[r]&&n.ignoreUndefined||(r in e&&e[r]!==Object.getPrototypeOf(e)?m(e,r,w(e[r],t[r],n)):m(e,r,O(t[r])))}),e);function w(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++)y.call(t,r)&&(i.push(String(r)),m(n,o++,t===e?t[r]:O(t[r])));n=j(n,t,A(t).filter(e=>!i.includes(e)),r)}),n})(e,t,r):h(t)&&h(e)?j(e,t,A(t),r):O(t)}var E={};const S=async(e,t)=>{const r=[];let n=0;for(const o of e)r.push(await t(await o,n++));return r};(E=S).default=S;var _={},T=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!p(e))throw new Error("`err` must be an Error");if(!Array.isArray(t))throw new Error("`fields` must be an Array");var r={};return Object.getOwnPropertyNames(Object.getPrototypeOf(e)).concat(Object.getOwnPropertyNames(e)).forEach((function(t){"function"!=typeof e[t]&&(r[t]=e[t])})),!r.name&&e.constructor.name&&(r.name=e.constructor.name),Array.isArray(t)&&0!==t.length?r.filter((function(e){return t.includes(e)})):r};const k=e=>"object"==typeof e||"function"==typeof e,P=(e,t)=>"__proto__"==e||"constructor"==e&&"function"==typeof t.constructor;var x=function(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:".";if(!k(e)||!t||!t.length)return e;const o=Array.isArray(t)?t:String(t).split(n);if(P(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];P(e,o)||(o=k(o[e])?o[e]:o[e]={})}return o[t[i]]=n,e})(e,o,i,r)},I=function(e){return null!=e&&"object"==typeof e&&!1===Array.isArray(e)};function L(e,t,r){return"function"==typeof r.join?r.join(e):e[0]+t+e[1]}function F(e,t,r){return"function"!=typeof r.isValid||r.isValid(e,t)}function M(e){return I(e)||Array.isArray(e)||"function"==typeof e}var N=Object.prototype.toString;function C(e){return"function"==typeof e.constructor?e.constructor.name:null}var D=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"===C(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(C(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=N.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}},X=function(e,t,r){return!(null==(n=e)||"object"!=typeof n&&"function"!=typeof n&&!Array.isArray(n)||"string"!=typeof t&&!Array.isArray(t))&&D(function(e,t,r){if(I(r)||(r={default:r}),!M(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||".",s=r.joinChar||("string"==typeof i?i:".");if(!o&&!n)return e;if(o&&t in e)return F(t,e,r)?e[t]:r.default;let c=n?t:function(e,t,r){return"function"==typeof r.split?r.split(e):e.split(t)}(t,i,r),a=c.length,f=0;do{let t=c[f];for("number"==typeof t&&(t=String(t));t&&"\\"===t.slice(-1);)t=L([t.slice(0,-1),c[++f]||""],s,r);if(t in e){if(!F(t,e,r))return r.default;e=e[t]}else{let n=!1,o=f+1;for(;o<a;)if(n=(t=L([t,c[o++]],s,r))in e){if(!F(t,e,r))return r.default;e=e[t],f=o-1;break}if(!n)return r.default}}while(++f<a&&M(e));return f===a?e:r.default}(e,t,r));var n};const B=e=>{if((e=>"__proto__"===e||"constructor"===e||"prototype"===e)(e))throw new Error(`Cannot set unsafe key: "${e}"`)};var H=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(X(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(),B(t),e=e[t];return delete e[i]}return!0},U={};Object.defineProperty(U,"__esModule",{value:!0}),U.boolean=void 0,U.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 W={};Object.defineProperty(W,"__esModule",{value:!0}),W.isBooleanable=void 0,W.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 z={};Object.defineProperty(z,"__esModule",{value:!0}),z.boolean=void 0,Object.defineProperty(z,"boolean",{enumerable:!0,get:function(){return U.boolean}}),Object.defineProperty(z,"isBooleanable",{enumerable:!0,get:function(){return W.isBooleanable}});var R,K,V,G="11.0.2",J=R={};function $(){throw new Error("setTimeout has not been defined")}function q(){throw new Error("clearTimeout has not been defined")}function Q(e){if(K===setTimeout)return setTimeout(e,0);if((K===$||!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:$}catch(e){K=$}try{V="function"==typeof clearTimeout?clearTimeout:q}catch(e){V=q}}();var Y,Z=[],ee=!1,te=-1;function re(){ee&&Y&&(ee=!1,Y.length?Z=Y.concat(Z):te=-1,Z.length&&ne())}function ne(){if(!ee){var e=Q(re);ee=!0;for(var t=Z.length;t;){for(Y=Z,Z=[];++te<t;)Y&&Y[te].run();te=-1,t=Z.length}Y=null,ee=!1,function(e){if(V===clearTimeout)return clearTimeout(e);if((V===q||!V)&&clearTimeout)return V=clearTimeout,clearTimeout(e);try{V(e)}catch(t){try{return V.call(null,e)}catch(t){return V.call(this,e)}}}(e)}}function oe(e,t){this.fun=e,this.array=t}function ie(){}J.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];Z.push(new oe(e,t)),1!==Z.length||ee||Q(ne)},oe.prototype.run=function(){this.fun.apply(null,this.array)},J.title="browser",J.browser=!0,J.env={},J.argv=[],J.version="",J.versions={},J.on=ie,J.addListener=ie,J.once=ie,J.off=ie,J.removeListener=ie,J.removeAllListeners=ie,J.emit=ie,J.prependListener=ie,J.prependOnceListener=ie,J.listeners=function(e){return[]},J.binding=function(e){throw new Error("process.binding is not supported")},J.cwd=function(){return"/"},J.chdir=function(e){throw new Error("process.chdir is not supported")},J.umask=function(){return 0};var se={};return function(t){(function(){const{boolean:n}=z,o=new Set(["config","log"]),s=["trace","debug","info","warn","error","fatal"],c={warning:"warn",err:"error"},a="`level` invalid, must be: "+s.join(", "),f=t.env.HOSTNAME||e.hostname();function y(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)}function d(e){return null==e||"object"==typeof e&&0===Object.keys(e).length||"string"==typeof e&&0===e.trim().length}function m(e){return void 0===e}function A(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function j(e){return"string"==typeof e}se=class{constructor(){var e=this;let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const i={};if(t.env.AXE_REMAPPED_META_FIELDS){const e=t.env.AXE_REMAPPED_META_FIELDS.split(",").map(e=>e.split(":"));for(const[t,r]of e)i[t]=r}this.config=function(){const e=w(O(v),this!==b&&this||{},v);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(!h(i))throw new TypeError("`"+i+"` is not an Option Object");t=w(t,{_:i},e)}return t._}({showStack:!t.env.AXE_SHOW_STACK||n(t.env.AXE_SHOW_STACK),meta:Object.assign({show:!t.env.AXE_SHOW_META||n(t.env.AXE_SHOW_META),remappedFields:i,omittedFields:t.env.AXE_OMIT_META_FIELDS?t.env.AXE_OMIT_META_FIELDS.split(",").map(e=>e.trim()):[],pickedFields:t.env.AXE_PICK_META_FIELDS?t.env.AXE_PICK_META_FIELDS.split(",").map(e=>e.trim()):[],cleanupRemapping:!0,hideHTTP:!0},"object"==typeof r.meta?r.meta:{}),version:G,silent:!1,logger:console,name:f,level:"info",levels:["info","warn","error","fatal"],appInfo:!t.env.AXE_APP_INFO||n(t.env.AXE_APP_INFO),hooks:Object.assign({pre:[],post:[]},"object"==typeof r.hooks?r.hooks:{})},r),this.appInfo=!!this.config.appInfo&&"function"==typeof _&&_(),this.log=this.log.bind(this);const c=Object.keys(this.config.logger).filter(e=>!o.has(e));for(const t of c)this[t]=this.config.logger[t];for(const t of s)"function"!=typeof this.config.logger[t]&&("fatal"===t?this.config.logger.fatal=this.config.logger.error||this.config.logger.info||this.config.logger.log:this.config.logger[t]=this.config.logger.info||this.config.logger.log),this[t]=function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return e.log(t,...Array.prototype.slice.call(n))};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(!j(e)||-1===s.indexOf(e))throw new Error(a);j(this.config.logger.logLevel)?this.config.logger.logLevel=e:this.config.logger.level=e,this.config.levels=s.slice(s.indexOf(e))}getNormalizedLevel(e){return j(e)?j(c[e])?c[e]:-1===s.indexOf(e)?"info":e:"info"}setName(e){if(!j(e))throw new Error("`name` must be a String");j(this.config.logger.scope)?this.config.logger.scope=e:this.config.logger.name=e}log(e,t,n){const o=[],a=[];m(e)||o.push(e),m(t)||o.push(t),m(n)||o.push(n);for(var f=arguments.length,h=new Array(f>3?f-3:0),b=3;b<f;b++)h[b-3]=arguments[b];for(const r of Array.prototype.slice.call(h))o.push(r);let v=0;if(j(e)&&j(c[e])?e=c[e]:p(e)?(n=t,t=e,e="error"):j(e)&&-1!==s.indexOf(e)||(n=t,t=e,e=this.getNormalizedLevel(e),v=-1),-1===this.config.levels.indexOf(e))return;let O,w=!1;if((A(t)||Array.isArray(t))&&j(n)){w=!0;const e=n;n=t,t=j(e)&&o.length>=3+v?u(...o.slice(2+v)):e}if(m(t)&&(t=e),1!==o.slice(1+v).length||j(t)||p(t))if(!w&&o.length>=4+v){t=void 0,n={};const r=[];for(const e of o)p(e)?a.push(e):j(e)&&r.push(e);0===a.length&&r.length>0?t=u(...r):a.length>0&&"log"===e&&(e="error")}else if(!w&&o.length===3+v&&j(t)&&l.some(e=>-1!==t.indexOf(e)))t=u(t,n),n={};else if(p(t)){if(p(n)){a.push(n);for(const e of o.slice(2+v))n!==e&&p(e)&&a.push(e);n={}}}else p(n)?(a.push(n),n={}):A(n)||m(n)||null===n?j(t)||(t=u(t)):(t=u(t,n),n={});else n={message:t},t=e;m(n)||A(n)?A(n)||(n={}):n={original_meta:n},p(t)&&(a.unshift(t),t=void 0),A(n.err)&&(p(n.err)&&a.push(n.err),n.original_err=p(n.err)?T(n.err):n.err),a.length>0&&(O=function(e){if(0!==(e=e.filter(i)).length)return 1===e.length?e[0]:new r(e)}(a),n.err=T(O),j(t)||(t=O.message)),n.level=e,this.appInfo&&(n.app=this.appInfo);const S=-1===v?"log":e;for(const r of this.config.hooks.pre)[O,t,n]=r(S,O,t,n);if(!d(this.config.meta.remappedFields))for(const r of Object.keys(this.config.meta.remappedFields))if(x(n,this.config.meta.remappedFields[r],g(n,r)),H(n,r),this.config.meta.cleanupRemapping){const e=r.lastIndexOf(".");if(-1===e)continue;const t=r.slice(0,e);d(g(n,t))&&H(n,t)}if(!d(this.config.meta.omittedFields)||!d(this.config.meta.pickedFields)){const e=function(e){const t=[];return function e(r,n){for(const o of Object.keys(r)){const i=r[o],s=n?n+"."+o:o;y(i)?e(i,s):t.push(s)}}(e),t}(n);if(!d(this.config.meta.omittedFields))for(const t of this.config.meta.omittedFields){let r=e.length;for(;r--;)e[r]!==t&&0!==e[r].indexOf(t+".")||e.splice(r,1)}if(!d(this.config.meta.pickedFields))for(const t of this.config.meta.pickedFields){const r=t.indexOf("."),n=t.slice(0,r+1);if(-1!==r){let t=e.length;for(;t--;)0===e[t].indexOf(n)&&e.splice(t,1)}-1===e.indexOf(t)&&e.push(t)}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||!Array.isArray(t)&&"string"!=typeof t)return{};var n;const{length:o}=t;if("string"==typeof t||o<2){const n="string"==typeof t?t:t[0],o=g(e,n,r);return void 0!==o?x({},n,o,r):{}}return((e,t,r,n)=>{const o={};for(let i=0;i<r;i++){const r=t[i],s=g(e,r,n);void 0!==s&&x(o,r,s,n)}return o})(e,t,o,r)}(n,e)}this.config.silent||(p(O)&&this.config.showStack?!this.config.meta.show||d(n)?this.config.logger[S](O):this.config.logger[S](O,n):!this.config.meta.show||d(n)||n.is_http&&this.config.meta.hideHTTP?this.config.logger[S](t):this.config.logger[S](t,n)),E(this.config.hooks.post,e=>e(S,O,t,n)).then().catch(e=>{this.config.logger.error(e)})}}}).call(this)}.call(this,R),se}));
|
package/lib/index.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
// eslint-disable-next-line import/no-unassigned-import
|
|
4
4
|
require('console-polyfill');
|
|
5
|
+
|
|
6
|
+
// eslint-disable-next-line unicorn/prefer-node-protocol
|
|
5
7
|
const os = require('os');
|
|
6
8
|
const combine = require('maybe-combine-errors');
|
|
7
9
|
const format = require('@ladjs/format-util');
|
|
@@ -93,7 +95,8 @@ class Axe {
|
|
|
93
95
|
remappedFields,
|
|
94
96
|
omittedFields: process.env.AXE_OMIT_META_FIELDS ? process.env.AXE_OMIT_META_FIELDS.split(',').map(s => s.trim()) : [],
|
|
95
97
|
pickedFields: process.env.AXE_PICK_META_FIELDS ? process.env.AXE_PICK_META_FIELDS.split(',').map(s => s.trim()) : [],
|
|
96
|
-
cleanupRemapping: true
|
|
98
|
+
cleanupRemapping: true,
|
|
99
|
+
hideHTTP: true
|
|
97
100
|
}, typeof config.meta === 'object' ? config.meta : {}),
|
|
98
101
|
version: pkg.version,
|
|
99
102
|
silent: false,
|
|
@@ -202,9 +205,6 @@ class Axe {
|
|
|
202
205
|
for (const arg of Array.prototype.slice.call(args)) {
|
|
203
206
|
originalArgs.push(arg);
|
|
204
207
|
}
|
|
205
|
-
const {
|
|
206
|
-
config
|
|
207
|
-
} = this;
|
|
208
208
|
let modifier = 0;
|
|
209
209
|
if (isString(level) && isString(aliases[level])) {
|
|
210
210
|
level = aliases[level];
|
|
@@ -220,7 +220,7 @@ class Axe {
|
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
// Return early if it is not a valid logging level
|
|
223
|
-
if (config.levels.indexOf(level) === -1) return;
|
|
223
|
+
if (this.config.levels.indexOf(level) === -1) return;
|
|
224
224
|
|
|
225
225
|
// Bunyan support (meta, message, ...args)
|
|
226
226
|
let isBunyan = false;
|
|
@@ -409,15 +409,17 @@ class Axe {
|
|
|
409
409
|
}
|
|
410
410
|
|
|
411
411
|
// only invoke logger methods if it was not silent
|
|
412
|
-
if (!config.silent) {
|
|
412
|
+
if (!this.config.silent) {
|
|
413
413
|
// Show stack trace if necessary (along with any metadata)
|
|
414
|
-
if (isError(err) && config.showStack) {
|
|
415
|
-
if (!config.meta.show || isEmpty(meta)) {
|
|
414
|
+
if (isError(err) && this.config.showStack) {
|
|
415
|
+
if (!this.config.meta.show || isEmpty(meta)) {
|
|
416
416
|
this.config.logger[method](err);
|
|
417
417
|
} else {
|
|
418
418
|
this.config.logger[method](err, meta);
|
|
419
419
|
}
|
|
420
|
-
} else if (!config.meta.show || isEmpty(meta)) {
|
|
420
|
+
} else if (!this.config.meta.show || isEmpty(meta)) {
|
|
421
|
+
this.config.logger[method](message);
|
|
422
|
+
} else if (meta.is_http && this.config.meta.hideHTTP) {
|
|
421
423
|
this.config.logger[method](message);
|
|
422
424
|
} else {
|
|
423
425
|
this.config.logger[method](message, meta);
|
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.0.
|
|
4
|
+
"version": "11.0.2",
|
|
5
5
|
"author": "Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com)",
|
|
6
6
|
"browser": {
|
|
7
7
|
"parse-app-info": false
|
|
@@ -32,36 +32,36 @@
|
|
|
32
32
|
"unset-value": "2.0.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@babel/cli": "^7.
|
|
36
|
-
"@babel/core": "^7.
|
|
37
|
-
"@babel/preset-env": "^7.
|
|
38
|
-
"@commitlint/cli": "^17.0
|
|
39
|
-
"@commitlint/config-conventional": "^17.0
|
|
40
|
-
"ava": "^
|
|
35
|
+
"@babel/cli": "^7.19.3",
|
|
36
|
+
"@babel/core": "^7.20.2",
|
|
37
|
+
"@babel/preset-env": "^7.20.2",
|
|
38
|
+
"@commitlint/cli": "^17.3.0",
|
|
39
|
+
"@commitlint/config-conventional": "^17.3.0",
|
|
40
|
+
"ava": "^5.1.0",
|
|
41
41
|
"babelify": "^10.0.0",
|
|
42
42
|
"browserify": "^17.0.0",
|
|
43
43
|
"consola": "^2.15.3",
|
|
44
44
|
"cross-env": "^7.0.3",
|
|
45
|
-
"eslint": "^8.
|
|
45
|
+
"eslint": "^8.28.0",
|
|
46
46
|
"eslint-config-xo-lass": "^2.0.1",
|
|
47
47
|
"eslint-plugin-compat": "^4.0.2",
|
|
48
48
|
"eslint-plugin-node": "^11.1.0",
|
|
49
|
-
"express": "^4.18.
|
|
49
|
+
"express": "^4.18.2",
|
|
50
50
|
"fixpack": "^4.0.0",
|
|
51
|
-
"husky": "^8.0.
|
|
51
|
+
"husky": "^8.0.2",
|
|
52
52
|
"jsdom": "15.x",
|
|
53
53
|
"koa": "^2.13.4",
|
|
54
|
-
"lint-staged": "^13.0.
|
|
54
|
+
"lint-staged": "^13.0.4",
|
|
55
55
|
"lodash": "^4.17.21",
|
|
56
56
|
"nyc": "^15.1.0",
|
|
57
|
-
"pino": "^8.
|
|
58
|
-
"remark-cli": "^
|
|
57
|
+
"pino": "^8.7.0",
|
|
58
|
+
"remark-cli": "^11.0.0",
|
|
59
59
|
"remark-preset-github": "^4.0.4",
|
|
60
60
|
"rimraf": "^3.0.2",
|
|
61
61
|
"signale": "^1.4.0",
|
|
62
|
-
"sinon": "^14.0.
|
|
62
|
+
"sinon": "^14.0.2",
|
|
63
63
|
"tinyify": "3.0.0",
|
|
64
|
-
"xo": "^0.
|
|
64
|
+
"xo": "^0.53.1"
|
|
65
65
|
},
|
|
66
66
|
"engines": {
|
|
67
67
|
"node": ">=14"
|