From 032d7584bc02835ba7b74f8a25cba94c75c30bf7 Mon Sep 17 00:00:00 2001 From: Tzipi-kaltura Date: Tue, 19 Nov 2024 15:46:15 +0200 Subject: [PATCH] add logger --- src/utils/duration-humanizer.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/duration-humanizer.ts b/src/utils/duration-humanizer.ts index 1aaca60f..d2220729 100644 --- a/src/utils/duration-humanizer.ts +++ b/src/utils/duration-humanizer.ts @@ -1,8 +1,9 @@ import * as humanizeDuration from 'humanize-duration'; import getLogger from './logger'; +let logger; + const getDurationAsText = (seconds: number, locale: string, round: boolean = false): string | undefined => { - const logger = getLogger('DurationHumanizer'); try { const durationHumanizer = getDurationHumanizer(locale); if (durationHumanizer) { @@ -13,6 +14,9 @@ const getDurationAsText = (seconds: number, locale: string, round: boolean = fal } } } catch (e: any) { + if (!logger) { + logger = getLogger('DurationHumanizer'); + } logger.log(e); } };