Skip to content

Commit

Permalink
fix trace log level not adding parameters to output (#5069)
Browse files Browse the repository at this point in the history
  • Loading branch information
rochdev authored Jan 7, 2025
1 parent daf7030 commit c7648a7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/dd-trace/src/log/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,17 @@ const log = {

Error.captureStackTrace(logRecord, this.trace)

const fn = logRecord.stack.split('\n')[1].replace(/^\s+at ([^\s]+) .+/, '$1')
const stack = logRecord.stack.split('\n')
const fn = stack[1].replace(/^\s+at ([^\s]+) .+/, '$1')
const params = args.map(a => {
return a && a.hasOwnProperty('toString') && typeof a.toString === 'function'
? a.toString()
: inspect(a, { depth: 3, breakLength: Infinity, compact: true })
}).join(', ')
const formatted = logRecord.stack.replace('Error: ', `Trace: ${fn}(${params})`)

traceChannel.publish(Log.parse(formatted))
stack[0] = `Trace: ${fn}(${params})`

traceChannel.publish(Log.parse(stack.join('\n')))
}
return this
},
Expand Down

0 comments on commit c7648a7

Please sign in to comment.