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B;IACH,CAAC;IAED,IAAI,CAAC,IAAY;QACf,uEAAuE;QACvE,IAAI,IAAI,CAAC,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;YACvD,OAAO,IAAA,qBAAU,EAAC,IAAI,EAAE,IAAA,sBAAe,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;SACpD;aAAM;YACL,OAAO,OAAO,CAAC,OAAO,EAAE,CAAA;SACzB;IACH,CAAC;CACF;AA1CD,kCA0CC","sourcesContent":["import { outputFile } from \"fs-extra\"\nimport { serializeToYaml } from \"./util\"\n\nexport class DebugLogger {\n readonly data: any = {}\n\n constructor(readonly isEnabled = true) {}\n\n add(key: string, value: any) {\n if (!this.isEnabled) {\n return\n }\n\n const dataPath = key.split(\".\")\n let o = this.data\n let lastName: string | null = null\n for (const p of dataPath) {\n if (p === dataPath[dataPath.length - 1]) {\n lastName = p\n break\n } else {\n if (o[p] == null) {\n o[p] = Object.create(null)\n } else if (typeof o[p] === \"string\") {\n o[p] = [o[p]]\n }\n o = o[p]\n }\n }\n\n if (Array.isArray(o[lastName!])) {\n o[lastName!] = [...o[lastName!], value]\n } else {\n o[lastName!] = value\n }\n }\n\n save(file: string) {\n // toml and json doesn't correctly output multiline string as multiline\n if (this.isEnabled && Object.keys(this.data).length > 0) {\n return outputFile(file, serializeToYaml(this.data))\n } else {\n return Promise.resolve()\n }\n }\n}\n"]}