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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | import type PinoPretty from 'pino-pretty'; import pretty from 'pino-pretty'; export default (options: PinoPretty.PrettyOptions) => pretty({ ...options, messageFormat( log: { id?: string; context?: string; prefix?: string; [messageKey: string]: unknown; config?: unknown; configBase?: unknown; req?: { method: string; url: string; headers?: Record<string, string>; body?: unknown; json?: unknown; }; res?: { statusCode: number; statusMessage: string; headers?: Record<string, string>; body?: unknown; }; $meta?: { mtid?: string; method?: string; }; }, messageKey, levelLabel, {colors}, ) { const { id, context, prefix, [messageKey]: message, config, configBase, req, res, $meta, } = log; return [ id && colors.dim(`semantic-log://record/${id}`), context && colors.greenBright(context), prefix, $meta?.mtid && colors.magenta($meta.mtid), $meta?.method && colors.yellow($meta.method), message, config && `\u001B]8;;blong://json/${JSON.stringify(config)}\u001B\\config\u001B]8;;\u001B\\`, configBase, req && !res && `▶ ${colors.magenta(req.method)} ${colors.yellow(req.url)}${ req.headers ? `\n${Object.entries(req.headers) .map( ([key, value]) => ` ${colors.blue(key)}: ${colors.green(value)}`, ) .join('\n')}` : '' }`, res && `◀ ${req ? `${colors.magenta(req.method)} ${colors.yellow(req.url)} ` : ''}${colors.blueBright(res.statusCode)}${ res.headers ? `\n${Object.entries(res.headers) .map( ([key, value]) => ` ${colors.blue(key)}: ${colors.green(value)}`, ) .join('\n')}` : '' }`, ] .filter(Boolean) .join(' '); }, }); |