MCPcopy Create free account
hub / github.com/getsentry/sentry-javascript / captureLog

Function captureLog

packages/node-core/src/logs/capture.ts:34–52  ·  view source on GitHub ↗
(level: LogSeverityLevel, ...args: CaptureLogArgs)

Source from the content-addressed store, hash-verified

32 * @param attributes - Arbitrary structured data that stores information about the log - e.g., userId: 100.
33 */
34export function captureLog(level: LogSeverityLevel, ...args: CaptureLogArgs): void {
35 const [messageOrMessageTemplate, paramsOrAttributes, maybeAttributesOrMetadata, maybeMetadata] = args;
36 if (Array.isArray(paramsOrAttributes)) {
37 // type-casting here because from the type definitions we know that `maybeAttributesOrMetadata` is an attributes object (or undefined)
38 const attributes = { ...(maybeAttributesOrMetadata as Log['attributes'] | undefined) };
39 attributes['sentry.message.template'] = messageOrMessageTemplate;
40 paramsOrAttributes.forEach((param, index) => {
41 attributes[`sentry.message.parameter.${index}`] = param;
42 });
43 const message = format(messageOrMessageTemplate, ...paramsOrAttributes);
44 _INTERNAL_captureLog({ level, message, attributes }, maybeMetadata?.scope);
45 } else {
46 _INTERNAL_captureLog(
47 { level, message: messageOrMessageTemplate, attributes: paramsOrAttributes },
48 // type-casting here because from the type definitions we know that `maybeAttributesOrMetadata` is a metadata object (or undefined)
49 (maybeAttributesOrMetadata as CaptureLogMetadata | undefined)?.scope ?? maybeMetadata?.scope,
50 );
51 }
52}

Callers 7

traceFunction · 0.90
debugFunction · 0.90
infoFunction · 0.90
warnFunction · 0.90
errorFunction · 0.90
fatalFunction · 0.90
logMethod · 0.90

Calls 2

_INTERNAL_captureLogFunction · 0.90
forEachMethod · 0.65

Tested by

no test coverage detected