deno.land / std@0.224.0 / log / formatters.ts
123456789101112131415161718192021222324252627// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.// This module is browser compatible.import type { LogRecord } from "./logger.ts";
export function jsonFormatter(logRecord: LogRecord): string { return JSON.stringify({ level: logRecord.levelName, datetime: logRecord.datetime.getTime(), message: logRecord.msg, args: flattenArgs(logRecord.args), });}
function flattenArgs(args: unknown[]): unknown { if (args.length === 1) { return args[0]; } else if (args.length > 1) { return args; }}
export const formatters: { jsonFormatter(logRecord: LogRecord): string;} = { jsonFormatter,};
Version Info