@@ -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
@@ -194,8 +194,11 @@ export function createConsolaReporter(options: ConsolaReporterOptions = {}): Con
194194
195195 return {
196196 log ( logObj : ConsolaLogObject ) {
197+ // We need to exclude certain known properties from being added as additional attributes
197198 // eslint-disable-next-line @typescript-eslint/no-unused-vars
198- const { type, level, message : consolaMessage , args, tag, date : _date , ...attributes } = logObj ;
199+ const { type, level, message : consolaMessage , args, tag, date : _date , ...rest } = logObj ;
200+
201+ const hasExtraLogObjKeys = Object . keys ( rest ) . length > 0 ;
199202
200203 // Get client - use provided client or current client
201204 const client = providedClient || getClient ( ) ;
@@ -223,6 +226,13 @@ export function createConsolaReporter(options: ConsolaReporterOptions = {}): Con
223226 }
224227 const message = messageParts . join ( ' ' ) ;
225228
229+ // Build attributes: `rest` properties from logObj get a "consola" prefix; base attributes added below may override
230+ const attributes : Record < string , unknown > = { } ;
231+
232+ for ( const [ key , value ] of Object . entries ( rest ) ) {
233+ attributes [ `consola.${ key } ` ] = value ;
234+ }
235+
226236 // Build attributes
227237 attributes [ 'sentry.origin' ] = 'auto.log.consola' ;
228238
@@ -239,6 +249,15 @@ export function createConsolaReporter(options: ConsolaReporterOptions = {}): Con
239249 attributes [ 'consola.level' ] = level ;
240250 }
241251
252+ // Extra keys on logObj (beyond reserved) indicate direct `reporter.log({ type, message, ...rest })`
253+ if ( hasExtraLogObjKeys && args && args . length >= 1 && typeof args [ 0 ] === 'string' ) {
254+ // Use first 'string' arg as message
255+ const message = args [ 0 ] ;
256+
257+ _INTERNAL_captureLog ( { level : logSeverityLevel , message, attributes } ) ;
258+ return ;
259+ }
260+
242261 _INTERNAL_captureLog ( {
243262 level : logSeverityLevel ,
244263 message,
0 commit comments