From cb2b47a7153b1bde304c7c06d3627ffc9576f7fa Mon Sep 17 00:00:00 2001 From: Roch Devost Date: Tue, 7 Jan 2025 12:04:30 -0500 Subject: [PATCH] fix trace log level not adding parameters to output (#5069) --- packages/dd-trace/src/log/index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/dd-trace/src/log/index.js b/packages/dd-trace/src/log/index.js index 3fb9afff6fa..8968a15f60b 100644 --- a/packages/dd-trace/src/log/index.js +++ b/packages/dd-trace/src/log/index.js @@ -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 },