Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 1x 1x 1x 16x 16x 16x 10x 1x 9x 9x 9x 11x 9x 9x 11x 11x | import type { LogLevel } from './LogLevel'; import { StringBuilder } from '../types'; import { inspect } from 'util'; export class BaseLogger { protected logMessage(level: LogLevel, verbose: boolean, functionName: string, description: string | null, details: Record<string, unknown> | null): string { const descriptionString = description !== null ? ` ${description}` : ''; const detailsString = verbose && details !== null ? `${description !== null ? ' |' : ''} ${this.detailsString(details)}` : ''; return `[${level.toUpperCase()}: ${functionName}]${descriptionString}${detailsString}`; } private detailsString(details: Record<string, unknown>): string { if (Object.keys(details).length === 0) return '{}'; const builder = new StringBuilder(); builder.appendLine('{'); for (const entry of Object.entries(details)) builder.appendLine(this.detailString(entry[0], entry[1])); builder.append('}'); return builder.toString(); } private detailString(key: string, detail: unknown): string { const jsonString = inspect(detail, { compact: true, depth: null, maxArrayLength: 25, maxStringLength: 250, breakLength: Number.POSITIVE_INFINITY }); return `\t${key}: ${jsonString}`; } } |