Skip to content

Commit

Permalink
chore: update logging
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackDark committed Jun 12, 2024
1 parent 18ec80a commit b045a2a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/custom-formats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ export const manageCf = async (cfProcessing: CFProcessing, serverCfs: Map<string
const comparison = compareObjectsCarr(existingCf, tr.requestConfig);

if (!comparison.equal) {
logger.info(`Found mismatch for ${tr.requestConfig.name}. ${comparison.changes}`);
logger.info(`Found mismatch for ${tr.requestConfig.name}: ${comparison.changes}`);

try {
if (IS_DRY_RUN) {
logger.info(`DryRun: Would update CF: ${existingCf.id} - ${existingCf.name}`);
updatedCFs++;
} else {
const updateResult = await api.v3CustomformatUpdate(existingCf.id + "", {
await api.v3CustomformatUpdate(existingCf.id + "", {
id: existingCf.id,
...tr.requestConfig,
});
Expand Down
8 changes: 4 additions & 4 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,23 +161,23 @@ export function compareObjectsCarr(object1: any, object2: any): { equal: boolean
}

if (!isEqual && changes.length <= 0) {
changes.push(`Mismatch found in array element at index ${i} for key ${key}`);
changes.push(`Mismatch found in array element at index ${i} for key '${key}'`);
}
}
} else if (typeof value2 === "object" && value2 !== null) {
if (typeof value1 !== "object" || value1 === null) {
changes.push(`Expected object for key ${key} in object1`);
changes.push(`Expected object for key '${key}' in object1`);
continue;
}

const { equal: isEqual, changes: subChanges } = compareObjectsCarr(value1, value2);
changes.push(...subChanges.map((subChange) => `${key}.${subChange}`));
if (!isEqual) {
changes.push(`Mismatch found for key ${key}`);
changes.push(`Mismatch found for key '${key}'`);
}
} else {
if (value1 !== value2) {
changes.push(`Mismatch found for key ${key}: server value ${value1}, value to set ${value2}`);
changes.push(`Mismatch found for key '${key}': server value '${value1}', value to set '${value2}'`);
}
}
} else {
Expand Down

0 comments on commit b045a2a

Please sign in to comment.