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 logging
DEVLOG_ENABLED=false
# Enable all logging (default)
DEVLOG_ENABLED=true

NODE_ENV

Devlog automatically disables debug logs in production. Set NODE_ENV to control this behavior:

bash
# Production - debug logs disabled
NODE_ENV=production
# Development - all logs enabled
NODE_ENV=development

Custom Logger Instance

Create a custom logger instance with specific configuration using the createLogger function:

typescript
import { createLogger } from "@promise-inc/devlog";
// Silent logger — always disabled
const silentLogger = createLogger({ enabled: false });
// Verbose logger — debug always on
const verboseLogger = createLogger({
enabled: true,
debugEnabled: true
});
// Environment-aware logger
const productionLogger = createLogger({
enabled: process.env.NODE_ENV !== "test",
debugEnabled: process.env.NODE_ENV === "development",
});
// Use custom logger
productionLogger.info("Using custom logger");
productionLogger.debug("This only shows in development");

Configuration Options

OptionTypeDefaultDescription
enabledbooleantrueEnable or disable all logging
debugEnabledbooleanNODE_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.