fix: vite conflicted configures

Signed-off-by: pakintada@gmail.com <Pakin>
This commit is contained in:
pakintada@gmail.com 2026-07-01 17:36:21 +07:00
parent 3cda8aa60b
commit 13b09e7bb9

View file

@ -14,7 +14,7 @@
* logger.error('Failed:', err)
* inspector.error('auth failure', uid) // always visible
*/
import { configureSync, getConsoleSink, withFilter, getLogger } from '@logtape/logtape';
import { configureSync, getConfig, getConsoleSink, withFilter, getLogger } from '@logtape/logtape';
// ---------------------------------------------------------------------------
// Environment helpers
@ -24,13 +24,14 @@ const IS_DEV = import.meta.env.DEV;
const ENV_LOG_LEVEL = (import.meta.env.PUBLIC_APP_LOG_LEVEL as string) || (IS_DEV ? 'trace' : 'info');
// ---------------------------------------------------------------------------
// LogTape configuration (singleton guard for Vite HMR / config reload)
// LogTape configuration (idempotent — uses getConfig() not a local flag)
// ---------------------------------------------------------------------------
let _configured = false;
function ensureConfigured() {
if (_configured) return;
_configured = true;
// Vite evaluates the config module twice during build (SSR + client).
// A local `_configured` boolean resets between evaluations, so we
// rely on LogTape's own global state instead.
if (getConfig() !== null) return;
configureSync({
sinks: {
console: getConsoleSink(),