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

Function setLogAttribute

packages/core/src/logs/internal.ts:29–38  ·  view source on GitHub ↗

* Sets a log attribute if the value exists and the attribute key is not already present. * * @param logAttributes - The log attributes object to modify. * @param key - The attribute key to set. * @param value - The value to set (only sets if truthy and key not present). * @param setEvenIfPresen

(
  logAttributes: Record<string, unknown>,
  key: string,
  value: unknown,
  setEvenIfPresent = true,
)

Source from the content-addressed store, hash-verified

27 * @param setEvenIfPresent - Whether to set the attribute if it is present. Defaults to true.
28 */
29function setLogAttribute(
30 logAttributes: Record<string, unknown>,
31 key: string,
32 value: unknown,
33 setEvenIfPresent = true,
34): void {
35 if (value && (!logAttributes[key] || setEvenIfPresent)) {
36 logAttributes[key] = value;
37 }
38}
39
40/**
41 * Captures a serialized log event and adds it to the log buffer for the given client.

Callers 1

_INTERNAL_captureLogFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected