Logging
llmist uses structured logging for debugging and monitoring.
Log Levels
Section titled “Log Levels”| Level | Priority | Use Case |
|---|---|---|
silly | 0 | Most verbose, internal state dumps |
trace | 1 | Detailed execution flow |
debug | 2 | Debugging information |
info | 3 | General operational info |
warn | 4 | Warnings (default) |
error | 5 | Errors that may need attention |
fatal | 6 | Critical failures |
Environment Variables
Section titled “Environment Variables”# Set log levelexport LLMIST_LOG_LEVEL="debug"
# Log to fileexport LLMIST_LOG_FILE="./llmist.log"
# Clear log file on startexport LLMIST_LOG_RESET="true"Variable Reference
Section titled “Variable Reference”| Variable | Description | Default |
|---|---|---|
LLMIST_LOG_LEVEL | Minimum log level | warn |
LLMIST_LOG_FILE | Path to log file | none (console only) |
LLMIST_LOG_RESET | Clear log file on start | false |
CLI Logging
Section titled “CLI Logging”Use command-line flags:
# Set log levelbunx @llmist/cli agent "task" --log-level debug
# Log to filebunx @llmist/cli agent "task" --log-file ./debug.log
# Combine optionsbunx @llmist/cli agent "task" --log-level trace --log-file ./trace.log# Set log levelnpx @llmist/cli agent "task" --log-level debug
# Log to filenpx @llmist/cli agent "task" --log-file ./debug.log
# Combine optionsnpx @llmist/cli agent "task" --log-level trace --log-file ./trace.logOr configure in ~/.llmist/cli.toml:
[agent]log-level = "debug"log-file = "~/.llmist/logs/agent.log"Programmatic Configuration
Section titled “Programmatic Configuration”Using .withLogger()
Section titled “Using .withLogger()”import { LLMist, createLogger } from 'llmist';
const logger = createLogger({ minLevel: 'debug',});
await LLMist.createAgent() .withLogger(logger) .askAndCollect('Your prompt');Custom Logger
Section titled “Custom Logger”import { createLogger } from 'llmist';
const logger = createLogger({ minLevel: 'debug', name: 'my-app',});
// Log directlylogger.debug('Custom message', { data: 'value' });logger.info('Agent started');logger.error('Something failed', { error });Silent Mode
Section titled “Silent Mode”Suppress all logging:
const logger = createLogger({ minLevel: 'fatal', // Only fatal errors});Log Output Format
Section titled “Log Output Format”Console output:
[2024-01-15 10:23:45] DEBUG (llmist): LLM call started model: "anthropic:claude-sonnet-4-5" messageCount: 3[2024-01-15 10:23:46] DEBUG (llmist): LLM call complete tokens: { input: 150, output: 80 } duration: 1234File output (structured JSON):
{"level":"debug","time":"2024-01-15T10:23:45.123Z","msg":"LLM call started","model":"anthropic:claude-sonnet-4-5"}Debugging with Logs
Section titled “Debugging with Logs”Capture LLM Interactions
Section titled “Capture LLM Interactions”LLMIST_LOG_LEVEL=trace bunx @llmist/cli agent "task" 2>&1 | tee debug.logLLMIST_LOG_LEVEL=trace npx @llmist/cli agent "task" 2>&1 | tee debug.logDebug Gadget Execution
Section titled “Debug Gadget Execution”const logger = createLogger({ minLevel: 'trace' });
await LLMist.createAgent() .withLogger(logger) .withGadgets(MyGadget) .askAndCollect('Test');Trace output shows:
- Gadget parameters received
- Execution timing
- Return values
Production Logging
Section titled “Production Logging”const isProd = process.env.NODE_ENV === 'production';
const logger = createLogger({ minLevel: isProd ? 'warn' : 'debug',});Integration with External Loggers
Section titled “Integration with External Loggers”Wrap external loggers:
import pino from 'pino';
const pinoLogger = pino({ level: 'debug' });
// Create adapterconst logger = { debug: (msg, data) => pinoLogger.debug(data, msg), info: (msg, data) => pinoLogger.info(data, msg), warn: (msg, data) => pinoLogger.warn(data, msg), error: (msg, data) => pinoLogger.error(data, msg),};
await LLMist.createAgent() .withLogger(logger) .askAndCollect('Task');See Also
Section titled “See Also”- Debugging Guide - Troubleshooting techniques
- CLI Configuration - CLI logging settings
- Hooks Guide - Custom monitoring with hooks