@@ -61,7 +61,7 @@ export interface ConsolaReporter {
6161 */
6262export interface ConsolaLogObject {
6363 /**
64- * Allows additional custom properties to be set on the log object.
64+ * Allows additional custom properties to be set on the log object (e.g. when reporter is called directly)
6565 * These properties will be captured as log attributes with a 'consola.' prefix.
6666 *
6767 * @example
@@ -187,8 +187,11 @@ export function createConsolaReporter(options: ConsolaReporterOptions = {}): Con
187187
188188 return {
189189 log ( logObj : ConsolaLogObject ) {
190+ // We need to exclude certain known properties from being added as additional attributes
190191 // eslint-disable-next-line @typescript-eslint/no-unused-vars
191- const { type, level, message : consolaMessage , args, tag, date : _date , ...attributes } = logObj ;
192+ const { type, level, message : consolaMessage , args, tag, date : _date , ...rest } = logObj ;
193+
194+ const hasExtraLogObjKeys = Object . keys ( rest ) . length > 0 ;
192195
193196 // Get client - use provided client or current client
194197 const client = providedClient || getClient ( ) ;
@@ -216,6 +219,13 @@ export function createConsolaReporter(options: ConsolaReporterOptions = {}): Con
216219 }
217220 const message = messageParts . join ( ' ' ) ;
218221
222+ // Build attributes: `rest` properties from logObj get a "consola" prefix; base attributes added below may override
223+ const attributes : Record < string , unknown > = { } ;
224+
225+ for ( const [ key , value ] of Object . entries ( rest ) ) {
226+ attributes [ `consola.${ key } ` ] = value ;
227+ }
228+
219229 // Build attributes
220230 attributes [ 'sentry.origin' ] = 'auto.log.consola' ;
221231
@@ -232,6 +242,15 @@ export function createConsolaReporter(options: ConsolaReporterOptions = {}): Con
232242 attributes [ 'consola.level' ] = level ;
233243 }
234244
245+ // Extra keys on logObj (beyond reserved) indicate direct `reporter.log({ type, message, ...rest })`
246+ if ( hasExtraLogObjKeys && args && args . length >= 1 && typeof args [ 0 ] === 'string' ) {
247+ // Use first 'string' arg as message
248+ const message = args [ 0 ] ;
249+
250+ _INTERNAL_captureLog ( { level : logSeverityLevel , message, attributes } ) ;
251+ return ;
252+ }
253+
235254 _INTERNAL_captureLog ( {
236255 level : logSeverityLevel ,
237256 message,
0 commit comments