Overview
TheLogLevel type defines the available log severity levels used throughout the HTTP Ledger Express middleware. It helps categorize logs based on their importance and the nature of the request/response cycle.
Type Definition
Values
'info'
Represents informational logs for normal, successful operations.
Typical use cases:
- Successful requests with 2xx status codes
- Normal request-response cycles
- Standard API operations
'warn'
Represents warning logs for potentially problematic situations that don’t prevent operation.
Typical use cases:
- Client errors with 4xx status codes
- Slow requests exceeding performance thresholds
- Deprecated API usage
- Rate limiting
'error'
Represents error logs for failures and exceptional conditions.
Typical use cases:
- Server errors with 5xx status codes
- Unhandled exceptions
- Database connection failures
- External service timeouts
Usage Examples
Using in Custom Log Level Function
Default Log Level Logic
When nocustomLogLevel function is provided, the middleware uses default logic:
Filtering Logs by Level
Advanced Custom Logic
TypeScript Type Checking
Integration with Logging Libraries
Best Practices
1. Consistent Level Assignment
Be consistent in how you assign log levels across your application:2. Consider Multiple Factors
Don’t rely solely on status codes:3. Environment-Specific Levels
Adjust log level thresholds based on environment:See Also
- LogData - The complete log data structure that includes logLevel
- ApiLoggerOptions - Configuration options including customLogLevel