Skip to content

Commit 57434de

Browse files
committed
readjust mapping
1 parent 81afabd commit 57434de

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

packages/pino-transport/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This transport forwards Pino logs to Sentry, allowing you to view and analyze yo
1010
npm install @sentry/pino-transport pino
1111
# or
1212
yarn add @sentry/pino-transport pino
13-
# or
13+
# or
1414
pnpm add @sentry/pino-transport pino
1515
```
1616

@@ -120,12 +120,12 @@ Pino log levels are automatically mapped to Sentry log severity levels:
120120

121121
Custom numeric levels are mapped to Sentry levels using ranges, so levels like `11`, `23`, or `42` will map correctly:
122122

123-
- `0-14``trace`
124-
- `15-24``debug`
125-
- `25-34``info`
126-
- `35-44``warn`
127-
- `45-54``error`
128-
- `55+``fatal`
123+
- `0-19``trace`
124+
- `20-29``debug`
125+
- `30-39``info`
126+
- `40-49``warn`
127+
- `50-59``error`
128+
- `60+``fatal`
129129

130130
```javascript
131131
import pino from 'pino';

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)