add_logpoint
Insert logpoints in PHP code to output variable values during execution without interrupting program flow, using {varName} placeholders for dynamic logging.
Instructions
Add a logpoint that logs messages without stopping execution. Use {varName} placeholders for variables.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | File path | |
| line | Yes | Line number | |
| message | Yes | Message template with {var} placeholders (e.g., 'User {$userId} logged in') | |
| condition | No | Optional condition |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"condition": {
"description": "Optional condition",
"type": "string"
},
"file": {
"description": "File path",
"type": "string"
},
"line": {
"description": "Line number",
"type": "integer"
},
"message": {
"description": "Message template with {var} placeholders (e.g., 'User {$userId} logged in')",
"type": "string"
}
},
"required": [
"file",
"line",
"message"
],
"type": "object"
}
Implementation Reference
- src/tools/advanced.ts:152-181 (registration)MCP tool registration for 'add_logpoint', including input schema, description, and handler function that delegates creation to LogpointManager.createLogpoint and returns formatted response.server.tool( 'add_logpoint', 'Add a logpoint that logs messages without stopping execution. Use {varName} placeholders for variables.', { file: z.string().describe('File path'), line: z.number().int().describe('Line number'), message: z.string().describe("Message template with {var} placeholders (e.g., 'User {$userId} logged in')"), condition: z.string().optional().describe('Optional condition'), }, async ({ file, line, message, condition }) => { const logpoint = ctx.logpointManager.createLogpoint(file, line, message, condition); return { content: [ { type: 'text', text: JSON.stringify({ success: true, logpoint: { id: logpoint.id, file, line, message, condition, }, }), }, ], }; } );
- Core implementation of logpoint creation: generates unique ID, initializes Logpoint object with properties, stores in internal map, and logs the creation.createLogpoint( file: string, line: number, message: string, condition?: string ): Logpoint { const id = `logpoint_${++this.logpointIdCounter}`; const logpoint: Logpoint = { id, file, line, message, condition, hitCount: 0, createdAt: new Date(), enabled: true, logHistory: [], }; this.logpoints.set(id, logpoint); logger.debug(`Logpoint created: ${id} at ${file}:${line}`); return logpoint; }
- Type definition for Logpoint objects used by the add_logpoint tool.export interface Logpoint { id: string; breakpointId?: string; file: string; line: number; message: string; condition?: string; hitCount: number; lastHitAt?: Date; createdAt: Date; enabled: boolean; logHistory: LogEntry[]; }