Skip to content

Commit f6d1e72

Browse files
authored
Migrate src/data-directory console statements to structured logger (#61074)
1 parent b27af36 commit f6d1e72

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

eslint.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ export default [
177177
'src/article-api/**/*.{ts,js}',
178178
'src/audit-logs/**/*.{ts,js}',
179179
'src/color-schemes/**/*.{ts,js}',
180-
'src/data-directory/**/*.{ts,js}',
181180
'src/dev-toc/**/*.{ts,js}',
182181
'src/events/components/**/*.{ts,js}',
183182
'src/fixtures/**/*.{ts,js}',

src/data-directory/lib/get-data.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import { merge, get } from 'lodash-es'
77

88
import languages from '@/languages/lib/languages-server'
99
import { correctTranslatedContentStrings } from '@/languages/lib/correct-translation-content'
10+
import { createLogger } from '@/observability/logger'
11+
12+
const logger = createLogger(import.meta.url)
1013

1114
interface YAMLException extends Error {
1215
mark?: any
@@ -128,7 +131,7 @@ export const getDataByLanguage = memoize((dottedPath: string, langCode: string):
128131
// would have caused a YAMLException
129132
if (langCode !== 'en') {
130133
if (DEBUG_JIT_DATA_READS) {
131-
console.warn(`Unable to parse Yaml in (${langCode}) '${dottedPath}': ${error.message}`)
134+
logger.warn('Unable to parse Yaml in translation', { langCode, dottedPath, error })
132135
}
133136
// Give it one more chance, but use English this time
134137
return getDataByDir(dottedPath, languages.en.dir)
@@ -208,7 +211,7 @@ function getDataByDir(
208211
return content
209212
}
210213
} else {
211-
console.warn(`Unable to find variables Yaml file ${fullPath.join(path.sep)}`)
214+
logger.warn('Unable to find variables Yaml file', { filePath: fullPath.join(path.sep) })
212215
}
213216
return undefined
214217
}
@@ -347,7 +350,7 @@ const getFileContent = (
347350
englishRoot?: string,
348351
): string => {
349352
const filePath = root ? path.join(root, relPath) : relPath
350-
if (DEBUG_JIT_DATA_READS) console.log('READ', filePath)
353+
if (DEBUG_JIT_DATA_READS) logger.info('READ', { filePath })
351354
try {
352355
return fs.readFileSync(filePath, 'utf-8')
353356
} catch (err) {

0 commit comments

Comments
 (0)