Repository navigation
Commit 9ead55d
authored
feat(core): Extract objects as structured logs in
Aligns the console integration so object-first logs are structured,
matching the consola integration behavior. If the first argument is an
object, the keys are added as log attributes.
Reference PR (consola):
#19534
The universal principle is this:
```
IF first_argument is plain_object:
attributes ← first_argument keys/values
message ← second_argument (if string) OR empty
remaining_args → sentry.message.parameter.{0, 1, 2...}
ELSE:
message ← formatted(all_args)
args[1:] → sentry.message.parameter.{0, 1, 2...}
```
### Example Snippet
```js
console.warn({ component: 'PaymentService', retryCount: 3 }, 500, 'TIMEOUT');
console.info(
{ userId: 42, action: 'purchase' },
'Console [OBJ-FIRST+PARAMS]: Checkout complete',
testOrder.orderId,
testOrder.total,
);
```
#### Before
<img width="1434" height="662" alt="image"
src="https://github.com/user-attachments/assets/19f310dd-d417-48fd-acb3-7695e28417b7"
/>
#### After
<img width="1425" height="665" alt="image"
src="https://github.com/user-attachments/assets/6f722ce3-e698-46fa-ba22-5f1f42304f65"
/>consoleLoggingIntegration (#21385)1 parent f52787f commit 9ead55d
3 files changed
Lines changed: 540 additions & 6 deletions
File tree
- packages/core
- src/logs
- test/lib/logs
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
7 | 21 | | |
8 | 22 | | |
9 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
61 | 83 | | |
62 | 84 | | |
63 | 85 | | |
| |||
0 commit comments