docs.rs failed to build browser_log-0.4.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build:
browser_log-0.3.0
📝 browser_log
Advanced logging and panic handling for WebAssembly applications
A specialized logging utility designed for Rust WebAssembly applications running in browsers and Node.js environments. Seamlessly integrates with JavaScript's console API while providing enhanced debugging capabilities and panic handling for WASM applications.
✨ Features
📊 Console Integration
- Multi-Level Logging - Debug, info, warn, error logging levels
- JavaScript Console API - Direct integration with browser developer tools
- Formatted Output - Structured log messages with timestamps and context
- Performance Logging - Timing and performance measurement utilities
🔧 Panic Management
- Panic Interception - Capture Rust panics in WASM environment
- Console Error Output - Redirect panic messages to console.error
- Stack Trace Preservation - Maintain debugging information across WASM boundary
- Graceful Error Handling - Prevent silent failures in web applications
🌐 Cross-Platform
- Browser Support - All modern browsers with WebAssembly support
- Node.js Compatible - Server-side WebAssembly applications
- Development Tools - Enhanced debugging experience in DevTools
- Production Ready - Configurable log levels for deployment
📦 Installation
Add to your Cargo.toml:
= { = true }
🚀 Quick Start
Basic Logging Setup
use *;
// Initialize logging (call once at startup)
// Use standard Rust logging macros
Advanced Configuration
use *;
use console;
📖 API Reference
Core Functions
| Function | Purpose | Example |
|---|---|---|
log::setup::setup() |
Initialize logger | browser_log::log::setup::setup(Default::default()) |
panic::setup() |
Setup panic handling | browser_log::panic::setup(Default::default()) |
console::log_1() |
Direct console output | console::log_1(&JsValue::from_str("message")) |
console::time() |
Performance timing | console::time() |
Logging Levels
// Standard Rust logging levels work seamlessly
trace!;
debug!;
info!;
warn!;
error!;
Console API
use console;
use JsValue;
// Direct console methods (using web-sys console API)
log_1;
info_1;
warn_1;
error_1;
// Performance timing
time;
// ... perform database query
time_end;
// Grouped logging
group_1;
log_1;
log_1;
group_end;
🎯 Use Cases
Web Application Development
- Frontend Debugging - Real-time debugging in browser DevTools
- Error Tracking - Capture and log runtime errors
- Performance Monitoring - Measure operation timing and performance
- User Activity Logging - Track user interactions and application state
Game Development
- Game State Debugging - Log game mechanics and state changes
- Performance Profiling - Monitor frame rates and render timing
- Asset Loading - Track resource loading progress
- Player Action Logging - Debug player input and game responses
Scientific Computing
- Algorithm Debugging - Trace complex calculation steps
- Data Processing - Log data transformation pipelines
- Visualization - Debug rendering and graphics operations
- Research Logging - Record experimental parameters and results
🔧 Advanced Features
Custom Panic Handlers
use *;
use panic;
// Custom panic handler with user notification
set_hook;
Conditional Logging
// Only log in debug builds
// Log with context information
Performance Profiling
use console;
// Usage
// Automatically logs timing when dropped
⚡ Best Practices
Production Deployment
- Use conditional compilation for debug logs
- Set appropriate log levels for production
- Consider log message size impact on bundle size
- Implement log throttling for high-frequency events
Development Workflow
- Use structured logging with consistent formatting
- Include context information in error messages
- Group related log messages for better organization
- Leverage browser DevTools filtering and search capabilities
🔧 Integration with Other Tools
With wasm-pack
[]
= { = true }
= "0.1"
With web frameworks
The logger integrates seamlessly with popular Rust web frameworks like Yew, Seed, and others that compile to WebAssembly.
📊 Technical Details
WebAssembly Compatibility
- Optimized for
wasm32-unknown-unknowntarget - Minimal overhead for high-performance applications
- Compatible with all WebAssembly runtimes
- Thread-safe for multi-threaded WASM applications (when supported)