Skip to content

Logging

llmist uses structured logging for debugging and monitoring.

LevelPriorityUse Case
silly0Most verbose, internal state dumps
trace1Detailed execution flow
debug2Debugging information
info3General operational info
warn4Warnings (default)
error5Errors that may need attention
fatal6Critical failures
Terminal window
# Set log level
export LLMIST_LOG_LEVEL="debug"
# Log to file
export LLMIST_LOG_FILE="./llmist.log"
# Clear log file on start
export LLMIST_LOG_RESET="true"
VariableDescriptionDefault
LLMIST_LOG_LEVELMinimum log levelwarn
LLMIST_LOG_FILEPath to log filenone (console only)
LLMIST_LOG_RESETClear log file on startfalse

Use command-line flags:

Terminal window
# Set log level
bunx @llmist/cli agent "task" --log-level debug
# Log to file
bunx @llmist/cli agent "task" --log-file ./debug.log
# Combine options
bunx @llmist/cli agent "task" --log-level trace --log-file ./trace.log

Or configure in ~/.llmist/cli.toml:

[agent]
log-level = "debug"
log-file = "~/.llmist/logs/agent.log"
import { LLMist, createLogger } from 'llmist';
const logger = createLogger({
minLevel: 'debug',
});
await LLMist.createAgent()
.withLogger(logger)
.askAndCollect('Your prompt');
import { createLogger } from 'llmist';
const logger = createLogger({
minLevel: 'debug',
name: 'my-app',
});
// Log directly
logger.debug('Custom message', { data: 'value' });
logger.info('Agent started');
logger.error('Something failed', { error });

Suppress all logging:

const logger = createLogger({
minLevel: 'fatal', // Only fatal errors
});

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: 1234

File output (structured JSON):

{"level":"debug","time":"2024-01-15T10:23:45.123Z","msg":"LLM call started","model":"anthropic:claude-sonnet-4-5"}
Terminal window
LLMIST_LOG_LEVEL=trace bunx @llmist/cli agent "task" 2>&1 | tee debug.log
const logger = createLogger({ minLevel: 'trace' });
await LLMist.createAgent()
.withLogger(logger)
.withGadgets(MyGadget)
.askAndCollect('Test');

Trace output shows:

  • Gadget parameters received
  • Execution timing
  • Return values
const isProd = process.env.NODE_ENV === 'production';
const logger = createLogger({
minLevel: isProd ? 'warn' : 'debug',
});

Wrap external loggers:

import pino from 'pino';
const pinoLogger = pino({ level: 'debug' });
// Create adapter
const 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');