Skip to content

Commit 1de514b

Browse files
committed
fix(logging): replace console.warn with logger in stars API route
The stars API route used console.warn() for error logging while every other API route in the codebase uses createLogger from @sim/logger. This makes warning output from this route invisible to the structured logging pipeline. Replaced both console.warn() calls with logger.warn() to match the pattern used across all other API routes.
1 parent ecd3536 commit 1de514b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

apps/sim/app/api/stars/route.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { NextResponse } from 'next/server'
2+
import { createLogger } from '@sim/logger'
23
import { env } from '@/lib/core/config/env'
34

5+
const logger = createLogger('StarsAPI')
6+
47
function formatStarCount(num: number): string {
58
if (num < 1000) return String(num)
69
const formatted = (Math.round(num / 100) / 10).toFixed(1)
@@ -22,14 +25,14 @@ export async function GET() {
2225
})
2326

2427
if (!response.ok) {
25-
console.warn('GitHub API request failed:', response.status)
28+
logger.warn('GitHub API request failed:', response.status)
2629
return NextResponse.json({ stars: formatStarCount(19400) })
2730
}
2831

2932
const data = await response.json()
3033
return NextResponse.json({ stars: formatStarCount(Number(data?.stargazers_count ?? 19400)) })
3134
} catch (error) {
32-
console.warn('Error fetching GitHub stars:', error)
35+
logger.warn('Error fetching GitHub stars:', error)
3336
return NextResponse.json({ stars: formatStarCount(19400) })
3437
}
3538
}

0 commit comments

Comments
 (0)