VibeCoding Logger
repository·main·Indexed 40 days ago
https://github.com/fladdict/vibe-loggerAn AI-native logging library for LLM agent development available in Python and TypeScript/Node.js. It generates structured JSON "AI briefing packages" containing rich context, correlation IDs, and dedicated fields like human_note and ai_todo to help LLMs debug and analyze code more effectively. Version 0.1.0.
What's inside VibeLogger
- VibeCoding Logger is a specialized logging system designed for AI-driven development. Unlike traditional logs meant for humans, it produces "AI briefing packages"—structured JSON data that provides Large Language Models (LLMs) with rich context, correlation tracking, and embedded human annotations to help them understand and debug code effectively.
What is VibeCoding Logger and how does it work?
mainVibeCoding Logger is an "AI-native" logging solution designed for the Vibe Coding methodology (where humans provide natural language instructions and AI generates code).
Unlike traditional loggers meant for human reading, VibeCoding Logger focuses on creating high-quality, structured data packages (JSON) that maximize information for LLMs. It allows developers to act as "diagnosticians" by providing rich context, stack traces, and direct instructions to the AI (the "surgeon").
Key conceptual pillars include:
- Structured JSON Output: Optimized for AI parsing.
- Rich Context: Captures operations, variable states, and correlation IDs.
- Human-to-AI Communication: Dedicated fields for human notes and AI tasks.
- Environment Capture: Automatically records runtime details (OS, language versions) for reproducibility.
Thread-safe logging in Python
mainThe
vibeloggerlibrary is fully thread-safe, making it suitable for concurrent or multi-threaded applications.import threading from vibelogger import create_file_logger logger = create_file_logger("multi_threaded_app") def worker(worker_id): logger.info( operation="worker_task", message=f"Worker {worker_id} processing", context={"worker_id": worker_id} ) # Safe to use across multiple threads threads = [threading.Thread(target=worker, args=(i,)) for i in range(10)] for t in threads: t.start()Implement correlation tracking for related operations
mainTo link related operations across your application, provide a
correlationIdwhen creating the logger. All subsequent logs from that instance will share the same ID, making it easy for an AI to reconstruct a sequence of events.// Use same correlation ID across related operations const correlationId = `request-${Date.now()}`; const logger = createLogger({ correlationId }); await logger.info('request_start', 'Processing API request'); await logger.info('auth_check', 'Validating credentials'); await logger.info('business_logic', 'Executing core logic'); await logger.info('request_end', 'Request completed'); // All logs will have the same correlation_idUnderstand the JSON Log Format
mainThe
vibeloggerTypeScript implementation produces JSON logs that are compatible with the Python version. Each log entry follows this structure:interface LogEntry { timestamp: string; // ISO 8601 UTC level: 'DEBUG' | 'INFO' | 'WARNING' | 'ERROR' | 'CRITICAL'; correlation_id: string; // UUID or custom operation: string; // What the code was trying to do message: string; // Human readable message context: Record<string, any>; // Rich context data environment: EnvironmentInfo; // Runtime environment source?: string; // File location and function stack_trace?: string; // Error stack trace human_note?: string; // Instructions for AI ai_todo?: string; // Specific AI tasks }Note on Naming: While the TypeScript API uses
camelCasefor parameters (e.g.,humanNote), the exported JSON format usessnake_case(e.g.,human_note) to maintain cross-language compatibility.interface LogEntry { timestamp: string; level: 'DEBUG' | 'INFO' | 'WARNING' | 'ERROR' | 'CRITICAL'; correlation_id: string; operation: string; message: string; context: Record<string, any>; environment: EnvironmentInfo; source?: string; stack_trace?: string; human_note?: string; ai_todo?: string; }Understand the VibeLogger JSON schema
mainVibeLogger emits structured JSON designed for LLM consumption. Key fields include:
timestamp: ISO format with UTC timezonelevel: Log level (e.g.,ERROR,INFO)correlation_id: Links related operations across the requestoperation: The specific task the code was attemptingmessage: Human-readable descriptioncontext: Structured data like function arguments, variables, or stateenvironment: Runtime info (e.g.,python_version,os) for reproductionsource: Exact file location and function namehuman_note: Natural language instructions for the AIai_todo: Specific analysis requests for the AI
{ "timestamp": "2025-07-07T08:36:42.123Z", "level": "ERROR", "correlation_id": "req_abc123", "operation": "fetchUserProfile", "message": "User profile not found", "context": { "user_id": "user-123", "query": "SELECT * FROM users WHERE id = ?" }, "environment": { "python_version": "3.11.0", "os": "Darwin" }, "source": "/app/user_service.py:42 in get_user_profile()", "human_note": "AI-TODO: Check database connection", "ai_todo": "Analyze why user lookup is failing" }How logException handles errors
mainThe
logExceptionmethod is designed to handle both standardErrorobjects and arbitrary values thrown in JavaScript (like strings or numbers). It normalizes these into a consistentErrorInfostructure to ensure the JSON log remains predictable.- If an
Errorobject is passed, it extractsmessage,stack, andname. - If a primitive is passed (e.g.,
throw 'error'), it converts the value to a string and sets the name toUnknownError.
logException(operation: string, error: Error | unknown, options?: LogOptions) { const errorInfo = this.extractErrorInfo(error); // ... normalization logic } private extractErrorInfo(error: unknown): ErrorInfo { if (error instanceof Error) { return { message: error.message, stack: error.stack, name: error.name }; } return { message: String(error), stack: undefined, name: 'UnknownError' }; }- If an
Enable AI-assisted debugging via CLAUDE.md
mainTo integrate VibeCoding Logger into your AI-driven workflow (e.g., using Claude Code), add the following instructions to your project's
CLAUDE.mdfile. This tells the AI to use the library and where to find debugging data.### Project Logging * Use vibelogger library for all logging needs * vibelogger instruction: https://github.com/fladdict/vibe-logger/blob/main/README.md * Check ./logs/<project_name>/ folder for debugging data when issues occur### Project Logging * Use vibelogger library for all logging needs * vibelogger instruction: https://github.com/fladdict/vibe-logger/blob/main/README.md * Check ./logs/<project_name>/ folder for debugging data when issues occurOptimize for memory-efficient logging (Python)
mainFor long-running processes where you want to avoid Out-Of-Memory (OOM) issues, disable in-memory log storage by setting
keep_logs_in_memory=Falsein theVibeLoggerConfig.from vibelogger import VibeLoggerConfig, create_logger # For long-running processes - disable memory storage config = VibeLoggerConfig( log_file="./logs/production.log", keep_logs_in_memory=False, # Don't store logs in memory auto_save=True ) logger = create_logger(config=config)Quick Start with createFileLogger
mainThe recommended way to start is using
createFileLogger, which automatically manages timestamped log files in a./logs/directory. This approach is ideal for capturing rich context for AI analysis.import { createFileLogger } from 'vibelogger'; // Create logger with auto-save to timestamped file const logger = createFileLogger('my-project'); // Log with rich context for AI analysis await logger.info('user_login', 'User authentication started', { context: { userId: '123', method: 'oauth', ipAddress: '192.168.1.100' }, humanNote: 'Monitor for suspicious patterns', aiTodo: 'Check if multiple failed attempts from this IP' }); // Log exceptions with full context try { await riskyOperation(); } catch (error) { await logger.logException('payment_processing', error, { context: { orderId: 'order-123', amount: 99.99 }, aiTodo: 'Suggest error handling improvements' }); } // Get logs formatted for AI analysis const aiContext = await logger.getLogsForAI(); console.log(aiContext); // Send this to your LLMInstall vibelogger via npm
mainInstall the
vibeloggerpackage using npm to start using AI-native logging in your Node.js/TypeScript project.npm install vibeloggerInstall VibeCoding Logger
mainInstall the library based on your target language:
Python
pip install vibeloggerTypeScript/Node.js
npm install vibeloggerpip install vibelogger # or npm install vibelogger