@resolid/app-log package provides structured logging capabilities for Resolid applications through integration with LogTape. It offers multiple log levels, category-based organization, and custom sinks for flexible log routing.
Installation
Basic Usage
Integrate logging into your Resolid application:Log Levels
LogTape provides five log levels, from lowest to highest severity:debug()
Detailed information for diagnosing problems:info()
General informational messages:warn()
Warning messages for potentially harmful situations:error()
Error messages for error events:fatal()
Very severe error events that might cause application termination:packages/app-log/src/index.ts:56-69
Category-Based Logging
Organize logs by category for better filtering and routing:category() method at packages/app-log/src/index.ts:71
Configuration
Basic Configuration
Configure logging with custom settings:Configuration Types
LogConfig (seepackages/app-log/src/index.ts:17):
packages/app-log/src/index.ts:15):
Sinks
Sinks control where logs are sent. LogTape provides several built-in sinks:Console Sink
Output logs to the console:File Sink
Write logs to a file:Custom Sink
Create your own sink:Advanced Features
Context-Aware Logging
Add contextual information to logs:withContext at packages/app-log/src/index.ts:79
Filtering Logs
Filter logs based on conditions:withFilter at packages/app-log/src/index.ts:80
Custom Log Targets
Integrate custom services as log targets:createLogTarget() at packages/app-log/src/index.ts:94
Common Patterns
Structured Logging
Log with structured data for better analysis:Error Logging with Stack Traces
Log errors with full context:Request Logging Middleware
Log all HTTP requests:Environment-Based Configuration
Configure logging differently for development and production:API Reference
LogService Class
See source atpackages/app-log/src/index.ts:28
createLogExtension()
Create a log extension for your Resolid app:packages/app-log/src/index.ts:104
createLogTarget()
Create a custom log target:packages/app-log/src/index.ts:94