Skip to content

Commit 398fe71

Browse files
committed
readjust mapping
1 parent 7a1c460 commit 398fe71

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

packages/pino-transport/src/index.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -215,30 +215,37 @@ function mapPinoLevelToSentryLevel(level: unknown, levelsConfig?: unknown): LogS
215215
* Maps a numeric level to the closest Sentry severity level using range-based mapping.
216216
* Handles both standard Pino levels and custom numeric levels.
217217
*
218+
* - `0-19` -> `trace`
219+
* - `20-29` -> `debug`
220+
* - `30-39` -> `info`
221+
* - `40-49` -> `warn`
222+
* - `50-59` -> `error`
223+
* - `60+` -> `fatal`
224+
*
218225
* @see https://github.com/pinojs/pino/blob/116b1b17935630b97222fbfd1c053d199d18ca4b/lib/constants.js#L6-L13
219226
*/
220227
function mapNumericLevelToSentryLevel(numericLevel: number): LogSeverityLevel {
221-
// 0-14 -> trace (includes standard 10)
222-
if (numericLevel < 15) {
228+
// 0-19 -> trace
229+
if (numericLevel < 20) {
223230
return 'trace';
224231
}
225-
// 15-24 -> debug (includes standard 20)
226-
if (numericLevel < 25) {
232+
// 20-29 -> debug
233+
if (numericLevel < 30) {
227234
return 'debug';
228235
}
229-
// 25-34 -> info (includes standard 30)
230-
if (numericLevel < 35) {
236+
// 30-39 -> info
237+
if (numericLevel < 40) {
231238
return 'info';
232239
}
233-
// 35-44 -> warn (includes standard 40)
234-
if (numericLevel < 45) {
240+
// 40-49 -> warn
241+
if (numericLevel < 50) {
235242
return 'warn';
236243
}
237-
// 45-54 -> error (includes standard 50)
238-
if (numericLevel < 55) {
244+
// 50-59 -> error
245+
if (numericLevel < 60) {
239246
return 'error';
240247
}
241-
// 55+ -> fatal (includes standard 60)
248+
// 60+ -> fatal
242249
return 'fatal';
243250
}
244251

0 commit comments

Comments
 (0)