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,KAAK,GAAS,CAAC,EAAG,EAAU,KACtB,KAAK,OAAO,IAAU,KAAK,OAAO,KAAK,SACzC,EAAI,CACF,MAAM,IAAI,MAAO,cACjB,QACA,IAAK,GAEH,iBAAiB,KACnB,EAAQ,EACR,EAAW,MAEb,EAAW,GAAY,KAAK,SACxB,MAAM,QAAQ,KACZ,KAAK,uBACP,EAAW,EAAS,OAAO,KAAK,mBAChC,EAAW,gBAAgB,IAE3B,EAAW,gBAAgB,IAG/B,KAAK,IAAI,MAAM,GAAG,GAChB,EACA,cAAc,CACZ,EACA,KAAK,sBACL,KAAK,gBAEP,GAAS,KAAK,SAAS,KAAK,aAChC,EAGJ,GAAI,KAAK,aAAc,CACrB,IAAI,EAAW,IACX,KAAK,sBACN,MAAM,SAAS,KAAK,oBAAqB,OAC1C,EAAoD,IAAzC,SAAS,KAAK,oBAAqB,KAEhD,MAAM,EAAmB,KACvB,GAAG,SAAS,KAAK,aAAc,QAAQ,CAAC,EAAK,KACtC,IACH,KAAK,MAAQ,EAAK,OACpB,GACD,EAEH,GAAG,UAAU,KAAK,aAAc,CAC9B,YAAY,EACZ,YACC,EACL,CACF,EAGF,GADA,QAAU,OAAO,QAAU,IACvB,QAAQ,OAAS,OAAQ,CAC3B,MAAM,EAAI,CACR,MAAO,IAAI,MAAM,0BACjB,KAAM,SACN,QAAS,CACP,OAAQ,eACR,KAAM,WACN,GAAI,KACJ,IAAK,SAEP,KAAM,CACJ,OAAQ,CACN,KAAM,CACJ,MAAO,CAAC,MAAO,EAAG,aAK1B,EAAE,SAAW,EACD,IAAI,IAAI,CAClB,MAAO,QAEP,uBAAuB,EACvB,oBAAqB,CAAC,eAAgB,SACtC,cAAe,iBACf,SAAU,CAAC,EAAK,IAAU,IAExB,MAAM,EAAG,CAAC,OAAQ,MAAO,EAC/B","file":"/npm/safe-json-log@0.0.7/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/safe-json-log@0.0.7/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","#!/usr/bin/env node\n\n'use strict'\nconst ss = require('json-stringify-safe')\nconst fs = require('fs')\nconst isStringOrNumber = (o) => o &&\n  Object.prototype.toString.call(o) === '[object String]' ||\n  !isNaN(parseInt(o, 10))\nconst multiReplacer = (replacers) => (key, value) => {\n  let result\n  for (const r of replacers) {\n    if (r) {\n      result = r(key, result || value)\n      if (result === undefined) {\n        return result\n      }\n    } else {\n      result = result || value\n    }\n  }\n  return result\n}\nconst excludeReplacer = (keys) => (key, value) =>\n  keys.includes(key) ? undefined : value\n// json-stringify-safe doesn't allow replacer arrays so we have to\n// create our own replacer to mimic the default JSON.stringify()\n// replacer array behavior.\nconst includeReplacer = (keys) => (key, value) =>\n  keys.includes(key) || key === '' ? value : undefined\nclass Log {\n  constructor(options) {\n    options = options || {}\n    this.level = 'off'\n    this.out = process.stdout\n    this.levels = {\n      trace: 0,\n      debug: 1,\n      info: 2,\n      warn: 3,\n      error: 4,\n      fatal: 5,\n      off: 6\n    }\n    this.replacer // (key, value) => value\n    // If you don't want to use errorReplacer, just set it to null or\n    // (key, value) => value\n    this.errorReplacer = (key, value) =>\n      value && value.name && value.message && value.stack ? {\n        name: value.name,\n        message: value.message,\n        stack: value.stack\n      } :\n      value\n    // replacerArrayIncludes = true causes the replacer (when it's an\n    // array) to work the same as the normal JSON.stringify(), i.e. we\n    // only include keys in the array.\n    // replacerArrayIncludes = false causes the replacer (when it's an\n    // array) to work the OPPOSITE as the normal JSON.stringify(), i.e. we\n    // exclude all keys in the array.\n    // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify\n    this.replacerArrayIncludes = true\n    // alwaysIncludeKeys specifies keys to always include (only valid when\n    // replacerArrayIncludes = true)\n    this.alwaysIncludeKeys = ['time', 'level', 'log', 'name', 'message', 'stack']\n    // values to always exclude.\n    this.alwaysExcludeValues = []\n    // excludedValue is what you want excluded values to be replaced with.\n    // if undefined, they key and the value are removed. if some other string\n    // value, just the value is replaced with excludedValue.\n    this.excludedValue = undefined\n    this.space = null\n    this.delimiter = '\\n'\n    this.logLevelFile = null\n    this.logLevelPollSeconds = 10\n    this.excludeValuesReplacer = (key, value) =>\n      this.alwaysExcludeValues.includes(value) ? this.excludedValue : value\n    Object.assign(this, options)\n    for (const level of Object.keys(this.levels)) {\n      this[level] = (o, replacer, space) => {\n        if (this.levels[level] >= this.levels[this.level]) {\n          o = {\n            time: new Date().toISOString(),\n            level,\n            log: o\n          }\n          if (isStringOrNumber(replacer)) {\n            space = replacer\n            replacer = null\n          }\n          replacer = replacer || this.replacer\n          if (Array.isArray(replacer)) {\n            if (this.replacerArrayIncludes) {\n              replacer = replacer.concat(this.alwaysIncludeKeys)\n              replacer = includeReplacer(replacer)\n            } else {\n              replacer = excludeReplacer(replacer)\n            }\n          }\n          this.out.write(`${ss(\n            o,\n            multiReplacer([\n              replacer,\n              this.excludeValuesReplacer,\n              this.errorReplacer,\n              ]),\n            space || this.space)}${this.delimiter}`)\n        }\n      }\n    }\n    if (this.logLevelFile) {\n      let interval = 10000\n      if (this.logLevelPollSeconds &&\n        !isNaN(parseInt(this.logLevelPollSeconds, 10))) {\n        interval = parseInt(this.logLevelPollSeconds, 10) * 1000\n      }\n      const readLogLevelFile = () => {\n        fs.readFile(this.logLevelFile, 'utf8', (err, data) => {\n          if (!err) {\n            this.level = data.trim()\n          }\n        })\n      }\n      fs.watchFile(this.logLevelFile, {\n        persistent: false,\n        interval\n      }, readLogLevelFile)\n    }\n  }\n}\nexports = module.exports = Log\nif (require.main === module) {\n  const o = {\n    error: new Error('something bad happened'),\n    name: 'freddy',\n    address: {\n      street: '1234 lane st',\n      city: 'hereshey',\n      st: 'PA',\n      zip: '19293'\n    },\n    nest: {\n      really: {\n        deep: {\n          stuff: ['one', 2, 'three']\n        }\n      }\n    }\n  }\n  o.circular = o\n  const log = new Log({\n    level: 'debug',\n    // logLevelFile: 'llf',\n    replacerArrayIncludes: false,\n    alwaysExcludeValues: ['1234 lane st', 'three'],\n    excludedValue: '***REDACTED***',\n    replacer: (key, value) => value\n  })\n  log.debug(o, ['trip', 'st'], 3)\n}\n"]}