deno.land / std@0.224.0 / log / formatters_test.ts

formatters_test.ts
View Documentation
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
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.import { assertEquals } from "../assert/mod.ts";import { FakeTime } from "../testing/time.ts";import { jsonFormatter } from "./formatters.ts";import { LogRecord } from "./logger.ts";
const log = (msg: string, args: unknown[] = []) => new LogRecord({ msg, args, level: 20, loggerName: "user-logger", });
Deno.test("jsonFormatter() handles messages without arguments", function () { using _time = new FakeTime(1);
assertEquals( jsonFormatter(log("msg")), `{"level":"INFO","datetime":1,"message":"msg"}`, );});
Deno.test("jsonFormatter() handles messages with one arguments", function () { using _time = new FakeTime(1);
assertEquals( jsonFormatter(log("msg", [{ user: "Dave" }])), `{"level":"INFO","datetime":1,"message":"msg","args":{"user":"Dave"}}`, );});
Deno.test("jsonFormatter() handles messages with many arguments", function () { using _time = new FakeTime(1);
assertEquals( jsonFormatter(log("msg", [1, true, null, [], {}])), `{"level":"INFO","datetime":1,"message":"msg","args":[1,true,null,[],{}]}`, );});
std

Version Info

Tagged at
6 months ago