Skip to main content
Stagehand provides a LogLine object. You can override the default logger by passing in a custom logger function to the constructor.
const stagehand = new Stagehand({
	logger: (logLine: LogLine) => {
		console.log(`[${logLine.category}] ${logLine.message}`);
	},
});
Below is the list of fields in the LogLine object. message is the main log message content, and auxiliary contains parameters that can be used to provide additional context and color to the log.
id
string
Unique identifier for the log line
category
string
Category/type of the log message
message
string
required
The main log message content
level
0 | 1 | 2
Logging verbosity level
timestamp
string
Timestamp of when the log was created
auxiliary
object
Additional metadata where each key contains a value and type. The value will always be a string, but type can be "object", "string", "html", "integer", "float", or "boolean"
You can see an example of a log line in OpenAIClient.ts. You’ll notice here how auxiliary contains a requestId and cachedResponse.
this.logger({
	category: "llm_cache",
	message: "LLM cache hit - returning cached response",
	level: 1,
	auxiliary: {
		requestId: {
			value: options.requestId,
			type: "string",
		},
		cachedResponse: {
			value: JSON.stringify(cachedResponse),
			type: "object",
		},
	}
});