From 2b49653f211813902b17f101f0a2fd93e693a946 Mon Sep 17 00:00:00 2001 From: Andrew Rumble Date: Fri, 25 Apr 2025 12:14:19 +0100 Subject: [PATCH] Improve logging This includes setting up the verbose mode appropriately GitOrigin-RevId: 6d7499467ae1ca80ca88963b14360931c7eb35e6 --- .../scripts/flush_projects_with_no_history_id.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/services/document-updater/scripts/flush_projects_with_no_history_id.js b/services/document-updater/scripts/flush_projects_with_no_history_id.js index 18c1644e4b..aa912b4b66 100644 --- a/services/document-updater/scripts/flush_projects_with_no_history_id.js +++ b/services/document-updater/scripts/flush_projects_with_no_history_id.js @@ -20,6 +20,8 @@ const { verbose, commit, ...args } = minimist(process.argv.slice(2), { }, }) +logger.logger.level(verbose ? 'debug' : 'warn') + const batchSize = parseInt(args.batchSize, 10) /** @@ -120,20 +122,25 @@ async function findDocsWithMissingHistoryIds(node, docIds) { */ async function fixAndFlushProjects(updates) { for (const update of updates) { - logger.debug({ ...update }, 'Flushing project') if (commit) { try { await rclient.set( docUpdaterKeys.projectHistoryId({ doc_id: update.docId }), update.historyId ) + logger.debug({ ...update }, 'Set history id in redis') await ProjectManager.promises.flushAndDeleteProjectWithLocks( update.projectId, {} ) + logger.debug({ ...update }, 'Flushed project') } catch (err) { logger.error({ err, ...update }, 'Error fixing and flushing project') } + } else { + logger.debug( + { ...update }, + 'Would have set history id in redis and flushed' ) } }