Initial import NDC_1C
This commit is contained in:
+31
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.logJson = logJson;
|
||||
const REDACT_KEYS = new Set(["apiKey", "authorization", "Authorization", "openai_api_key", "OPENAI_API_KEY"]);
|
||||
function redactObject(value) {
|
||||
if (Array.isArray(value)) {
|
||||
return value.map(redactObject);
|
||||
}
|
||||
if (value !== null && typeof value === "object") {
|
||||
const source = value;
|
||||
const out = {};
|
||||
for (const [key, field] of Object.entries(source)) {
|
||||
if (REDACT_KEYS.has(key)) {
|
||||
out[key] = "***REDACTED***";
|
||||
}
|
||||
else {
|
||||
out[key] = redactObject(field);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
function logJson(entry) {
|
||||
const safe = {
|
||||
...entry,
|
||||
details: redactObject(entry.details)
|
||||
};
|
||||
// Structured JSON logs for diagnostics/trace aggregation.
|
||||
process.stdout.write(JSON.stringify(safe) + "\n");
|
||||
}
|
||||
Reference in New Issue
Block a user