From 7566aa8765be82a9773b7ff83c3ddc8e70041e79 Mon Sep 17 00:00:00 2001 From: Marcos Casagrande Date: Wed, 20 May 2020 16:27:01 +0200 Subject: [PATCH] fix(std/log): await default logger setup (#5341) --- std/log/mod.ts | 2 +- std/log/mod_test.ts | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 std/log/mod_test.ts diff --git a/std/log/mod.ts b/std/log/mod.ts index 4032937a25..983e824015 100644 --- a/std/log/mod.ts +++ b/std/log/mod.ts @@ -127,4 +127,4 @@ export async function setup(config: LogConfig): Promise { } } -setup(DEFAULT_CONFIG); +await setup(DEFAULT_CONFIG); diff --git a/std/log/mod_test.ts b/std/log/mod_test.ts new file mode 100644 index 0000000000..ceedcc8586 --- /dev/null +++ b/std/log/mod_test.ts @@ -0,0 +1,16 @@ +// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. +const { test } = Deno; +import { Logger } from "./logger.ts"; +import { assert } from "../testing/asserts.ts"; +import { getLogger } from "./mod.ts"; + +let logger: Logger | null = null; +try { + // Need to initialize it here + // otherwise it will be already initialized on Deno.test + logger = getLogger(); +} catch {} + +test("logger is initialized", function (): void { + assert(logger instanceof Logger); +});