BeagleLog class. This provides a consistent interface for tracking, filtering, and displaying different types of events in your application.
BeagleLog Abstract Class
All logs in Beagle extend theBeagleLog abstract class, which provides core functionality:
Core Properties
id: string
id: string
A unique identifier for each log entry. Auto-generated using
nanoid(6) to create a short, URL-safe ID. Can be provided manually for log updates (like network request/response pairs).time: Date
time: Date
The timestamp when the log was created. Used for chronological ordering and displaying relative times in the inspector.
message: string
message: string
The primary display text for the log. This appears in the log list and is searchable.
level: LogLevel
level: LogLevel
The severity/type of the log, which determines its visual appearance and icon.
Log Levels
Beagle supports five log levels, each with distinct visual styling:loading
loading
Indicates an ongoing operation. Commonly used for network requests that haven’t completed yet.Visual: Spinner or progress indicator
Example: Network request pending response
Example: Network request pending response
info
info
General informational messages. The default level for most logs.Visual: Blue/neutral color
Example: “User navigated to Settings screen”
Example: “User navigated to Settings screen”
warning
warning
Potential issues that don’t prevent operation but deserve attention.Visual: Yellow/orange color
Example: HTTP 3xx redirects, deprecated API usage
Example: HTTP 3xx redirects, deprecated API usage
error
error
Errors and failures that need immediate attention.Visual: Red color
Example: Network failures, caught exceptions, HTTP 4xx/5xx responses
Example: Network failures, caught exceptions, HTTP 4xx/5xx responses
success
success
Successful completion of an operation.Visual: Green color
Example: HTTP 2xx responses, successful data fetches
Example: HTTP 2xx responses, successful data fetches
How Logs Are Tracked
Logs flow through a centralized system managed byBeaglePlugins:
1. Log Creation
Any code can create a log by instantiating aBeagleLog subclass:
2. Queueing
If the system isn’t ready (provider not mounted), logs are queued:This ensures logs created during app initialization aren’t lost.
3. Storage
Once the provider is ready, logs are added to React state and displayed in the inspector:4. Display
The appropriate plugin is found and used to render the log:Built-in Log Types
Beagle includes three built-in log types, each designed for specific use cases:MessageLog
The simplest log type, used for general messages:ErrorLog
Captures JavaScript errors with full context:- Automatically extracts error message
- Stores the full error object for inspection
- Always uses ‘error’ level
NetworkingLog
Tracks HTTP requests and responses:- Parses URL into host and path
- Automatically determines log level from response status
- Supports updating from ‘loading’ to final status
- Enhanced filtering by URL and host
- Tracks request/response timing
- No response:
loading - Status 2xx:
success - Status 3xx:
warning - Status 4xx/5xx or error:
error
NetworkingLog can be created without a response, then updated with the same ID when the response arrives. This allows the log to transition from ‘loading’ to the final state.
Custom Filtering
Logs can override thefilter() method to customize search behavior. For example, NetworkingLog also searches the host: