add_logpoint
Add a logpoint to PHP code that logs messages during execution without stopping the program. Use {varName} placeholders to include variable values in log output.
Instructions
Add a logpoint that logs messages without stopping execution. Use {varName} placeholders for variables.
Input Schema
TableJSON 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 |
Implementation Reference
- src/tools/advanced.ts:152-181 (handler)The core handler implementation for the 'add_logpoint' MCP tool. Registers the tool, defines input schema with Zod, creates the logpoint via LogpointManager, and returns a JSON-formatted success response with logpoint details.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, }, }), }, ], }; } );
- src/tools/advanced.ts:155-160 (schema)Zod schema for input validation of the add_logpoint tool parameters.{ 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'), },
- Helper method in LogpointManager that creates, initializes, and stores a new Logpoint instance. Called by the tool handler.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; }
- TypeScript interface defining the Logpoint data structure used by the manager and 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[]; }
- src/tools/index.ts:61-61 (registration)Registration call to registerAdvancedTools function, which includes the add_logpoint tool registration, invoked from the main registerAllTools.registerAdvancedTools(server, ctx as AdvancedToolsContext);