Logger Extension
The Logger extension is a development tool that logs all lifecycle events to the browser console. It’s useful for debugging and understanding the extension system.
Installation
Section titled “Installation”ESM (Module Bundlers)
Section titled “ESM (Module Bundlers)”UMD (CDN)
Section titled “UMD (CDN)”Features
Section titled “Features”- Lifecycle logging - Logs all extension lifecycle events
- Image initialization - Logs when images are initialized
- Navigation tracking - Logs image view events
- Open/close tracking - Logs lightbox open and close events
- Console output - All logs use
console.debug()for easy filtering
What Gets Logged
Section titled “What Gets Logged”The logger uses console.debug() for all output. Each hook logs a label string followed by the raw data object on a second line.
onInitializeImage
Section titled “onInitializeImage”Logged once per image during setup:
onOpen
Section titled “onOpen”Logged when the lightbox opens:
onImageView
Section titled “onImageView”Logged when navigating to an image:
onContentChange
Section titled “onContentChange”Logged when image content changes (pan, zoom, etc.):
onClose
Section titled “onClose”Logged when the lightbox closes:
Usage Example
Section titled “Usage Example”Open your browser’s developer console and interact with the lightbox to see the logs.
Filtering Logs
Section titled “Filtering Logs”The logger uses console.debug(), so you can filter logs in your browser’s developer console:
Chrome/Edge
Section titled “Chrome/Edge”- Open DevTools (F12)
- Go to Console tab
- Select log levels and choose “Verbose” or “Debug”
Firefox
Section titled “Firefox”- Open Developer Tools (F12)
- Go to Console tab
- Click the filter icon and enable “Debug”
Safari
Section titled “Safari”- Open Web Inspector (Cmd+Option+I)
- Go to Console tab
- Click the filter icon and enable “Debug”
Bundle Size
Section titled “Bundle Size”- ESM: 0.61 KB (0.23 KB gzip)
- UMD: 0.76 KB (0.37 KB gzip)
Use Cases
Section titled “Use Cases”Debugging Custom Extensions
Section titled “Debugging Custom Extensions”Understanding Event Order
Section titled “Understanding Event Order”Use the logger to understand the order of lifecycle events:
Then interact with the lightbox and observe the console:
Development vs Production
Section titled “Development vs Production”Only include the logger in development:
Next Steps
Section titled “Next Steps”- Learn about creating custom extensions
- Explore other extensions
- See events and lifecycle