Log Levels
The SDK supports five log levels, from most to least verbose:'debug'- Show all messages including HTTP request/response details'info'- Show informational messages, warnings, and errors'warn'- Show warnings and errors (default)'error'- Show only errors'off'- Disable all logging
Setting the Log Level
You can configure the log level in two ways:- Client Option
- Environment Variable
Set the
logLevel option when creating the client:The
logLevel client option takes precedence over the LIMRUN_LOG environment variable.Debug Logging
At the'debug' level, all HTTP requests and responses are logged, including headers and bodies:
Custom Logger
By default, the SDK logs toglobalThis.console. You can provide a custom logger that implements the standard logging interface.
The SDK is compatible with popular logging libraries including:
Using Pino
Using Winston
Using Consola
Logger Interface
If you’re implementing a custom logger, it must provide these methods:The
logLevel option still controls which messages are emitted. Messages below the configured level will not be sent to your custom logger.Log Message Format
Log messages include contextual information to help with debugging:- Request ID: Unique identifier for correlating log entries (e.g.,
[log_a1b2c3]) - HTTP Method & URL: The request being made
- Status Code: Response status
- Duration: Time taken for the request in milliseconds
- Retry Information: Whether the request is a retry
Retry Logging
When requests are retried, logs include retry information:Production Recommendations
Use 'warn' or 'error' in production
The default
'warn' level is suitable for most production environments. It captures important issues without excessive verbosity.Enable 'debug' only when troubleshooting
Use debug logging temporarily when investigating issues. Remember that it logs request/response bodies which may contain sensitive data.
Use structured logging
Consider using a structured logger like pino or winston to enable better log aggregation and analysis in production.
Related
Error Handling
Learn about error handling and debugging
Retries and Timeouts
Configure retry behavior and timeouts