@@ -6,6 +6,7 @@ import { toMarkdown } from 'mdast-util-to-markdown'
66import yaml from 'js-yaml'
77import { type Node , type Nodes , type Definition , type Link } from 'mdast'
88
9+ import { createLogger } from '@/observability/logger'
910import frontmatter from '@/frame/lib/read-frontmatter'
1011import {
1112 getPathWithLanguage ,
@@ -20,6 +21,8 @@ import getRedirect, { splitPathByLanguage } from '@/redirects/lib/get-redirect'
2021import nonEnterpriseDefaultVersion from '@/versions/lib/non-enterprise-default-version'
2122import { deprecated } from '@/versions/lib/enterprise-server-releases'
2223
24+ const logger = createLogger ( import . meta. url )
25+
2326// That magical string that can be turned into the actual title when
2427// we, at runtime, render out the links
2528const AUTOTITLE = 'AUTOTITLE'
@@ -55,7 +58,7 @@ export async function updateInternalLinks(files: string[], options = {}) {
5558 ...( await updateFile ( file , context , opts ) ) ,
5659 } )
5760 } catch ( err ) {
58- console . warn ( `The file it tried to process on exception was: ${ file } ` )
61+ logger . warn ( 'File processing failed' , { file } )
5962 throw err
6063 }
6164 }
@@ -149,7 +152,7 @@ async function updateFile(
149152 // bubble up to the CLI. And the CLI will mention which file it
150153 // was processing when it failed. But we have a valuable piece of
151154 // information here about which frontmatter key it was that failed.
152- console . warn ( `The frontmatter key it processed and failed was ' ${ key } '` )
155+ logger . warn ( 'Frontmatter key processing failed' , { key } )
153156 throw error
154157 }
155158 }
@@ -281,9 +284,10 @@ async function updateFile(
281284 newContent = newContent . replace ( asMarkdown , newAsMarkdown )
282285 }
283286 } else if ( opts . verbose ) {
284- console . warn (
285- `Unable to find link as Markdown ('${ asMarkdown } ') in the source content (${ file } )` ,
286- )
287+ logger . warn ( 'Unable to find link as Markdown in the source content' , {
288+ asMarkdown,
289+ file,
290+ } )
287291 }
288292 } )
289293
@@ -394,7 +398,7 @@ function getNewFrontmatterLinkList(
394398 const better = [ ]
395399 for ( const entry of list ) {
396400 if ( / { % \s * e l s e \s * % } / . test ( entry ) ) {
397- console . warn ( ` Skipping frontmatter link with {% else %} in it: ${ entry } . ( file: ${ file } )` )
401+ logger . warn ( ' Skipping frontmatter link with {% else %} in it' , { entry, file } )
398402 better . push ( entry )
399403 continue
400404 }
@@ -419,7 +423,7 @@ function getNewFrontmatterLinkList(
419423 if ( opts . strict ) {
420424 throw new Error ( msg )
421425 }
422- console . warn ( `WARNING: ${ msg } ` )
426+ logger . warn ( msg , { file , pure , lineNumber } )
423427 better . push ( entry )
424428 } else {
425429 // Perhaps it just redirected to a specific version
@@ -512,7 +516,7 @@ function getNewHref(
512516 if ( opts . strict ) {
513517 throw new Error ( msg )
514518 } else {
515- console . warn ( `WARNING: ${ msg } ` )
519+ logger . warn ( msg , { file , href : newHref } )
516520 return
517521 }
518522 }
@@ -530,7 +534,7 @@ function getNewHref(
530534 if ( opts . strict ) {
531535 throw new Error ( msg )
532536 } else {
533- console . warn ( `WARNING: ${ msg } ` )
537+ logger . warn ( msg , { file , href } )
534538 return
535539 }
536540 }
@@ -569,7 +573,7 @@ function getNewHref(
569573 if ( opts . strict ) {
570574 throw new Error ( msg )
571575 } else {
572- console . warn ( msg )
576+ logger . warn ( msg , { file } )
573577 return
574578 }
575579 } else if ( withoutLanguage . startsWith ( '/enterprise-server@latest' ) ) {
0 commit comments