Skip to content

Commit 8fc2470

Browse files
committed
don't use message
1 parent bf884b1 commit 8fc2470

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

packages/core/src/integrations/consola.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,20 @@ export interface ConsolaLogObject {
123123
/**
124124
* The raw arguments passed to the log method.
125125
*
126-
* When `message` is not provided, these args are typically formatted into the final message.
126+
* These args are typically formatted into the final `message`. In Consola reporters, `message` is not provided.
127127
*
128128
* @example
129129
* ```ts
130130
* consola.info('Hello', 'world', { user: 'john' });
131131
* // args = ['Hello', 'world', { user: 'john' }]
132132
* ```
133+
*
134+
* @example
135+
* ```ts
136+
* // `message` is a reserved property in Consola
137+
* consola.log({ message: 'Hello' });
138+
* // args = ['Hello']
139+
* ```
133140
*/
134141
args?: unknown[];
135142

packages/core/test/lib/integrations/consola.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ describe('createConsolaReporter', () => {
112112
['trace', 'trace'],
113113
['fatal', 'fatal'],
114114
] as const)('maps type "%s" to Sentry level "%s"', (type, expectedLevel) => {
115-
sentryReporter.log({ type, message: `${type} message` });
115+
sentryReporter.log({ type, args: [`${type} message`] });
116116

117117
expect(_INTERNAL_captureLog).toHaveBeenCalledWith(
118118
expect.objectContaining({
@@ -132,7 +132,7 @@ describe('createConsolaReporter', () => {
132132
['log', 'info'],
133133
['silent', 'trace'],
134134
] as const)('maps consola type "%s" to Sentry level "%s"', (type, expectedLevel) => {
135-
sentryReporter.log({ type, message: `Test ${type}` });
135+
sentryReporter.log({ type, args: [`Test ${type}`] });
136136

137137
expect(_INTERNAL_captureLog).toHaveBeenCalledWith(
138138
expect.objectContaining({
@@ -149,7 +149,7 @@ describe('createConsolaReporter', () => {
149149
it('uses level number when type is missing', () => {
150150
sentryReporter.log({
151151
level: 0, // Fatal level
152-
message: 'Fatal message',
152+
args: ['Fatal message'],
153153
});
154154

155155
expect(_INTERNAL_captureLog).toHaveBeenCalledWith(
@@ -174,21 +174,21 @@ describe('createConsolaReporter', () => {
174174
// Should capture error
175175
filteredReporter.log({
176176
type: 'error',
177-
message: 'Error message',
177+
args: ['Error message'],
178178
});
179179
expect(_INTERNAL_captureLog).toHaveBeenCalledTimes(1);
180180

181181
// Should capture warn
182182
filteredReporter.log({
183183
type: 'warn',
184-
message: 'Warn message',
184+
args: ['Warn message'],
185185
});
186186
expect(_INTERNAL_captureLog).toHaveBeenCalledTimes(2);
187187

188188
// Should not capture info
189189
filteredReporter.log({
190190
type: 'info',
191-
message: 'Info message',
191+
args: ['Info message'],
192192
});
193193
expect(_INTERNAL_captureLog).toHaveBeenCalledTimes(2);
194194
});
@@ -200,7 +200,7 @@ describe('createConsolaReporter', () => {
200200
['trace', 'debug', 'info', 'warn', 'error', 'fatal'].forEach(type => {
201201
defaultReporter.log({
202202
type,
203-
message: `${type} message`,
203+
args: [`${type} message`],
204204
});
205205
});
206206

0 commit comments

Comments
 (0)