Configuration
Environment Variables
Devlog can be configured using environment variables to control logging behavior in different environments.
DEVLOG_ENABLED
Control whether devlog is enabled. Set to 'false' to disable all logging:
bash
# Disable all loggingDEVLOG_ENABLED=false
# Enable all logging (default)DEVLOG_ENABLED=trueNODE_ENV
Devlog automatically disables debug logs in production. Set NODE_ENV to control this behavior:
bash
# Production - debug logs disabledNODE_ENV=production
# Development - all logs enabledNODE_ENV=developmentCustom Logger Instance
Create a custom logger instance with specific configuration using the createLogger function:
typescript
import { createLogger } from "@promise-inc/devlog";
// Silent logger — always disabledconst silentLogger = createLogger({ enabled: false });
// Verbose logger — debug always onconst verboseLogger = createLogger({ enabled: true, debugEnabled: true});
// Environment-aware loggerconst productionLogger = createLogger({ enabled: process.env.NODE_ENV !== "test", debugEnabled: process.env.NODE_ENV === "development",});
// Use custom loggerproductionLogger.info("Using custom logger");productionLogger.debug("This only shows in development");Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
| enabled | boolean | true | Enable or disable all logging |
| debugEnabled | boolean | NODE_ENV !== 'production' | Enable or disable debug logs |
Custom logger instances are useful when you need different logging behavior for different parts of your application, such as a verbose logger for a specific module or a silent logger for tests.