* 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, )
| 27 | * @param setEvenIfPresent - Whether to set the attribute if it is present. Defaults to true. |
| 28 | */ |
| 29 | function 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. |
no outgoing calls
no test coverage detected