You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2.2 KiB
2.2 KiB
Logging
Imwald uses src/lib/logger.ts for application logs. Prefer it over direct console.* calls in shared code.
Overview
Current behavior:
- Development without debug mode:
info,warn, anderrorare logged with formatted prefixes. - Development with debug mode:
debug,info,warn,error, component logs, and performance logs are available. - Production: only
warnanderrorare emitted, without formatted timestamp/caller strings.
Usage
Browser Console
In development mode, you can control logging from the browser console:
imwaldLogger.setDebugMode(true)
imwaldLogger.setDebugMode(false)
imwaldLogger.isDebugEnabled()
jumbleLogger is still exposed as a legacy alias in development.
For Code
Use the logger instead of direct console statements:
import logger from '@/lib/logger'
// Debug logging (only shows in dev mode with debug enabled)
logger.debug('Debug information', data)
// Info logging (development only by default)
logger.info('Important information', data)
// Warning logging
logger.warn('Warning message', data)
// Error logging
logger.error('Error message', data)
// Performance logging (development only)
logger.perf('Performance metric', data)
Log Levels
- debug: Development debugging information (disabled in production)
- info: Development application information
- warn: Warning messages (always enabled)
- error: Error messages (always enabled)
- perf: Performance metrics (development only)
Configuration
The logger automatically configures itself based on:
- Environment: Debug logging is disabled in production builds
- Local Storage:
imwald-debug=trueenables debug mode (legacy:jumble-debug=true) - Environment Variable:
VITE_DEBUG=trueenables debug mode
Debug Mode
To enable debug mode:
-
In Browser Console (development only):
imwaldLogger.setDebugMode(true) -
Via Local Storage:
localStorage.setItem('imwald-debug', 'true') -
Via Environment Variable:
VITE_DEBUG=true npm run dev
Debug mode shows debug-level logs with timestamps, levels, and caller hints.