(quoteValue: (s: string) => string, whitespace?: number | string | undefined)
| 177 | * @internal |
| 178 | */ |
| 179 | const format = (quoteValue: (s: string) => string, whitespace?: number | string | undefined) => |
| 180 | ( |
| 181 | { annotations, cause, date, fiberId, logLevel, message, spans }: Logger.Logger.Options<unknown> |
| 182 | ): string => { |
| 183 | const formatValue = (value: string): string => value.match(textOnly) ? value : quoteValue(value) |
| 184 | const format = (label: string, value: string): string => `${logSpan_.formatLabel(label)}=${formatValue(value)}` |
| 185 | const append = (label: string, value: string): string => " " + format(label, value) |
| 186 | |
| 187 | let out = format("timestamp", date.toISOString()) |
| 188 | out += append("level", logLevel.label) |
| 189 | out += append("fiber", fiberId_.threadName(fiberId)) |
| 190 | |
| 191 | const messages = Arr.ensure(message) |
| 192 | for (let i = 0; i < messages.length; i++) { |
| 193 | out += append("message", Inspectable.toStringUnknown(messages[i], whitespace)) |
| 194 | } |
| 195 | |
| 196 | if (!Cause.isEmptyType(cause)) { |
| 197 | out += append("cause", Cause.pretty(cause, { renderErrorCause: true })) |
| 198 | } |
| 199 | |
| 200 | for (const span of spans) { |
| 201 | out += " " + logSpan_.render(date.getTime())(span) |
| 202 | } |
| 203 | |
| 204 | for (const [label, value] of annotations) { |
| 205 | out += append(label, Inspectable.toStringUnknown(value, whitespace)) |
| 206 | } |
| 207 | |
| 208 | return out |
| 209 | } |
| 210 | |
| 211 | /** @internal */ |
| 212 | const escapeDoubleQuotes = (s: string) => `"${s.replace(/\\([\s\S])|(")/g, "\\$1$2")}"` |
no test coverage detected