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"
VariableDescriptionDefault
LLMIST_LOG_LEVELMinimum log levelwarn

Use command-line flags:

Terminal window
# Set log level
npx @llmist/cli agent "task" --log-level debug
# Enable trace for maximum verbosity
npx @llmist/cli agent "task" --log-level trace

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

[agent]
log-level = "debug"
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 npx @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');