diff --git a/package.json b/package.json index 4ab61fc..0a516ae 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "zeed", "type": "module", - "version": "0.25.8", + "version": "0.25.9", "description": "🌱 Simple foundation library", "author": { "name": "Dirk Holtwick", @@ -71,17 +71,17 @@ "devDependencies": { "@antfu/eslint-config": "^3.8", "@antfu/ni": "^0.23.0", - "@types/node": "^22.8.1", + "@types/node": "^22.9.0", "@vitejs/plugin-vue": "^5.1.4", - "@vitest/browser": "^2.1.3", - "@vitest/coverage-v8": "^2.1.3", + "@vitest/browser": "^2.1.4", + "@vitest/coverage-v8": "^2.1.4", "esbuild": "^0.24.0", "eslint": "^9", "playwright": "^1.48.2", "tsup": "^8.3.5", "typescript": "^5.6.3", "vite": "^5.4.10", - "vitest": "^2.1.3" + "vitest": "^2.1.4" }, "pnpm": { "overrides": { diff --git a/src/browser/log/log-browser-factory.ts b/src/browser/log/log-browser-factory.ts index 1fadf0e..73b2b85 100644 --- a/src/browser/log/log-browser-factory.ts +++ b/src/browser/log/log-browser-factory.ts @@ -3,7 +3,6 @@ import { LogLevelAll, LogLevelDebug, LogLevelError, LogLevelFatal, LogLevelInfo, import { browserSelectColorByName } from '../../common/log/log-colors' import { getGlobalConsole } from '../../common/log/log-console-original' import { parseLogLevel, useNamespaceFilter } from '../../common/log/log-filter' -import { getLocalStorage } from '../../common/platform' import { browserSupportsColors } from './log-colors' /** @@ -12,8 +11,11 @@ import { browserSupportsColors } from './log-colors' * loggers will not work any more. */ export function LoggerBrowserSetupDebugFactory(opt: LogHandlerOptions = {}) { - const localStorage = getLocalStorage() - const filter = opt.filter ?? localStorage?.zeed ?? localStorage?.debug + const filter = opt.filter ?? ( + typeof localStorage !== 'undefined' + ? (localStorage.zeed ?? localStorage.debug) + : undefined) + const styleFont = 'font-family: "JetBrains Mono", Menlo; font-size: 11px;' const styleDefault = `${styleFont}` const styleBold = `font-weight: 600; ${styleFont}` diff --git a/src/browser/log/log-context-browser.ts b/src/browser/log/log-context-browser.ts index 68db309..04bf4e1 100644 --- a/src/browser/log/log-context-browser.ts +++ b/src/browser/log/log-context-browser.ts @@ -3,14 +3,13 @@ import type { LogConfig } from '../../common/log/log-config' import { isEmpty } from '../../common/data/is' import { getGlobalLogger } from '../../common/log/log' import { _LoggerFromConfig } from '../../common/log/log-config' -import { getLocalStorage, isBrowser } from '../../common/platform' +import { isBrowser } from '../../common/platform' import { LoggerBrowserHandler } from './log-browser' import { LoggerBrowserSetupDebugFactory } from './log-browser-factory' export function Logger(name?: string, level?: LogLevelAliasType): LoggerInterface { return getGlobalLogger((context) => { - const localStorage = getLocalStorage() - if (isBrowser() && !isEmpty(localStorage?.getItem('zeed'))) { + if (isBrowser() && (typeof localStorage !== 'undefined' ? !isEmpty(localStorage?.getItem('zeed')) : false)) { context.setHandlers([LoggerBrowserHandler()]) // Fallback for previously registered Loggers context.setFactory(LoggerBrowserSetupDebugFactory({})) }