From bb9529b877522885a46d3833cc2be7dc354043cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B2=81=E6=A0=91=E4=BA=BA?= Date: Sat, 14 Sep 2024 20:53:44 +0100 Subject: [PATCH] fix: performance logging code --- .env | 2 +- src/util/logUtils.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.env b/.env index bcc85c2..d45c717 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ # Example environment file for vite to use. # For more information, see: https://vitejs.dev/guide/env-and-mode.html -ENABLE_PERF_LOG=0 +VITE_ENABLE_PERF_LOG=0 diff --git a/src/util/logUtils.ts b/src/util/logUtils.ts index 29430b5..d691faa 100644 --- a/src/util/logUtils.ts +++ b/src/util/logUtils.ts @@ -1,25 +1,25 @@ import { wrapFunctionCall } from './fnWrapper'; export function timedLogger(label: string, fn: () => R): R { - if (import.meta.env.ENABLE_PERF_LOG !== '1') { + if (import.meta.env.VITE_ENABLE_PERF_LOG !== '1') { return fn(); } else { return wrapFunctionCall( () => console.time(label), () => console.timeEnd(label), - fn + fn, ); } } export function withGroupedLogs(label: string, fn: () => R): R { - if (import.meta.env.ENABLE_PERF_LOG !== '1') { + if (import.meta.env.VITE_ENABLE_PERF_LOG !== '1') { return fn(); } else { return wrapFunctionCall( () => console.group(label), () => (console.groupEnd as (label: string) => void)(label), - () => timedLogger(`${label}/total`, fn) + () => timedLogger(`${label}/total`, fn), ); } } @@ -37,7 +37,7 @@ const dummyLogger = { }; export function getLogger() { - if (import.meta.env.ENABLE_PERF_LOG === '1') { + if (import.meta.env.VITE_ENABLE_PERF_LOG === '1') { return window.console; } else { return dummyLogger;