Skip to content

Commit b27af36

Browse files
authored
Migrate src/events console statements to structured logger (#61073)
1 parent fccfa41 commit b27af36

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

eslint.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export default [
179179
'src/color-schemes/**/*.{ts,js}',
180180
'src/data-directory/**/*.{ts,js}',
181181
'src/dev-toc/**/*.{ts,js}',
182-
'src/events/**/*.{ts,js}',
182+
'src/events/components/**/*.{ts,js}',
183183
'src/fixtures/**/*.{ts,js}',
184184
'src/github-apps/**/*.{ts,js}',
185185
'src/journeys/**/*.{ts,js}',

src/events/lib/hydro.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const { NODE_ENV, HYDRO_SECRET, HYDRO_ENDPOINT } = process.env
1818
const inProd = NODE_ENV === 'production'
1919

2020
if (inProd && (isNil(HYDRO_SECRET) || isNil(HYDRO_ENDPOINT))) {
21-
console.warn(
21+
logger.warn(
2222
'Running in production but HYDRO_SECRET and HYDRO_ENDPOINT environment variables are not set.',
2323
)
2424
}

src/events/middleware.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { createLogger } from '@/observability/logger'
12
import express from 'express'
23
import { omit, without, mapValues } from 'lodash-es'
34
import QuickLRU from 'quick-lru'
@@ -17,6 +18,8 @@ import { DOTCOM_USER_COOKIE_NAME, STAFFONLY_COOKIE_NAME } from '@/frame/lib/cons
1718
import { analyzeComment, getGuessedLanguage } from './lib/analyze-comment'
1819
import { EventType, EventProps, EventPropsByType } from './types'
1920

21+
const logger = createLogger(import.meta.url)
22+
2023
const router = express.Router()
2124
const OMIT_FIELDS = ['type']
2225
const allowedTypes = new Set(without(Object.keys(schemas), 'validation'))
@@ -103,7 +106,7 @@ router.post(
103106
value: omit(body, OMIT_FIELDS),
104107
})
105108
} catch (eventError) {
106-
console.error('Error validating event:', eventError)
109+
logger.error('Error validating event', { error: eventError })
107110
}
108111
}
109112
if (validEvents.length > 0) {

0 commit comments

Comments
 (0)