Web Daterangepicker includes a powerful, category-based logging system built on loglevel. Enable detailed debug logs during development or troubleshoot production issues via
the browser console API.
Quick Start
Enable logging globally for all categories:
When enabled, you'll see color-coded logs in your browser console with timestamps:
[14:32:15.234] [DEBUG] [DRP] Week starts on day: 0[14:32:15.235] [INFO] [DRP:RENDERING] Rendering calendar[14:32:15.240] [WARN] [DRP:VALIDATION] Date disabled[14:32:15.245] [ERROR] [DRP:SELECTION] Invalid date rangeLogging Categories
The logger uses a hierarchical category system for granular control. Enable only the categories you need:
| Category | Description | Use When |
|---|---|---|
DRP | Core initialization and lifecycle | Component won't initialize, options not applied |
DRP:RENDERING | Calendar rendering and DOM updates | Calendar not visible, dates not displaying correctly |
DRP:INTERACTION | User interactions (clicks, hovers, keyboard) | Clicks not working, keyboard navigation broken |
DRP:SELECTION | Date selection logic | Dates not selecting, range not working |
DRP:NAVIGATION | Month/year navigation | Navigation buttons not working, wrong month shown |
DRP:UI | Show/hide calendar, positioning | Calendar won't open, positioning incorrect |
DRP:VALIDATION | Date validation and restrictions | Disabled dates not working, validation issues |
DRP:DRAG | Drag-to-adjust range functionality | Drag behavior not working in range mode |
Configuration API
Control logging programmatically at application startup:
Enable All Logging
Disable All Logging
Set Global Log Level
Set Category-Specific Level
Browser Console API
Control logging at runtime via the browser console - no rebuild required! This is perfect for debugging production issues or testing on the fly.
Access the API
Enable/Disable Logging
Set Log Levels
List Available Categories
Common Use Cases
Calendar not working in production? Enable logging in the browser console to see what's happening without redeploying.
Experimenting with date restrictions or validation? Enable validation logging to see how dates are being processed in real-time.
Verify you're using the correct version of the component with
window.components['web-daterangepicker'].version()Not sure what categories are available? Call
getCategories() to see the full list.Benefits
- No Rebuild Required: Toggle logging instantly in production
- Selective Debugging: Enable only the categories you need to investigate
- Runtime Inspection: Check component version and configuration
- Safe for Production: All logging functions are SSR-safe
- Per-Instance Control: Each component instance respects global settings
- Zero Code Changes: Debug issues without modifying your source code
Common Debugging Scenarios
Calendar Not Rendering
Selection Not Working
Navigation Issues
Drag Behavior Problems
Output Format
All log messages follow a consistent format for easy parsing and filtering in browser devtools:
[HH:MM:SS.mmm] [LEVEL] [CATEGORY] messageFormat Breakdown:
- Timestamp: 24-hour time with milliseconds for precise timing
- Level: DEBUG, INFO, WARN, or ERROR
- Category: Hierarchical category (e.g., DRP:RENDERING)
- Message: The actual log content
Color Coding
| Level | Color | Use Case |
|---|---|---|
| DEBUG | ■ Blue | Detailed diagnostic information |
| INFO | ■ Green | Informational messages about normal operation |
| WARN | ■ Orange | Potential issues or unexpected states |
| ERROR | ■ Red | Errors that prevent normal operation |
Best Practices
1. Enable Only in Development
Logging has minimal overhead when disabled, but it's still best to avoid it in production:
2. Use Category-Specific Logging
Instead of enabling all logs, focus on the category you're debugging:
3. Different Levels for Different Categories
4. Configuration Warnings Are Always Visible
Important configuration issues are logged via console.warn or console.error and are always visible, regardless of logging
settings:
- Invalid configuration options
- Deprecated API usage
- Missing required attributes
Performance
Library Size:
loglevel: ~1KB gzippedloglevel-plugin-prefix: ~500B gzipped
Runtime Performance:
- Disabled logs: <1 microsecond per log call (negligible)
- Enabled logs: ~50-100 microseconds per log call (only in development)
- Production builds: Tree-shaken if not imported
Implementation Details
Why loglevel?
- Lightweight (~1KB) and battle-tested
- Zero dependencies
- Works in all browsers and Node.js
- Supports log levels and filtering
- Extensible via plugins
Logger Structure
Troubleshooting
Logs Not Appearing
- Check if logging is enabled:
- Check browser console filters: Make sure you haven't filtered out console logs in your devtools settings
- Check log level: Some logs may be at INFO or WARN level. Try setting debug
level:
- Verify component is loaded: Check that the web component is registered:
Too Many Logs
- Use category-specific logging: Enable only what you need
- Increase log level: Use 'info' or 'warn' instead of 'debug'
- Filter in devtools: Use browser console filtering to search for specific messages