Skip to content

Conversation

@butschster
Copy link
Collaborator

@butschster butschster commented Mar 14, 2025

PSR-3 Logger Implementation with Console Support

This PR adds a fully PSR-3 compliant logging system with console output support. The implementation is designed to integrate seamlessly with Symfony Console, respecting verbosity levels and providing colored output.

image

New Components:

  • ConsoleLogger: PSR-3 compatible logger that outputs to Symfony Console
  • LogLevel: Enum mapping PSR log levels to ANSI colors and verbosity settings
  • FormatterInterface & SimpleFormatter: Message formatting and context interpolation
  • NullLogger: No-op implementation for disabled logging scenarios
  • LoggerFactory: Creates appropriate loggers based on runtime environment

Features:

  • Verbosity-aware output: Respects console verbosity flags (-v, -vv, -vvv)
  • Color-coded messages: Different log levels appear in distinct colors

Add Display Command for Configuration Visualization

Overview

This PR introduces a new display command that allows users to view their context configuration in a human-readable, color-coded format directly in the terminal. This makes it easier to debug configuration issues and understand complex configurations without having to open and parse JSON files manually.

ctx display [config-file]

This will show a detailed, color-highlighted breakdown of their configuration including all documents, sources, and modifiers.

Context: context.json
=====================

Total documents: 6


Document 1/6:
=====================

  Description: "Recent Git Changes"
  Output Path: "docs/recent-changes.md"
  Overwrite: true

    Text Source
    ===========
    Description: "Documentation Header"
    Tag: "description"
    Content Preview: ""# Recent Git Changes\n\nThis document contains recent changes from the git repository.\n""

    Git Diff Source
    ==============
    Description: "Recent Commits (Last 1)"
    Repository: "./."
    Commit Range: "unstaged"
    File Pattern: "*.*"
    Exclude Patterns: ["vendor", "tests"]
    Show Stats: true



Document 2/6:
=====================

  Description: "Sources."
  Output Path: "api/sources.md"
  Overwrite: true

    File Source
    ===========
    Source Paths: ["./test"]
    File Pattern: "*.php"
    Ignore Unreadable Dirs: false
    Show Tree View: true

    File Source
    ===========
    Source Paths: ["./src/Source", "./src/Lib/Content"]
    File Pattern: "*.php"
    Ignore Unreadable Dirs: false
    Show Tree View: true

    Modifiers: 1

    Modifier 1/10:
      Content Sanitizer Modifier
      --------------------------

      Options:
        Rules: [{
          "type": "keyword"
          "keywords": ["tet"]
        }]



Document 3/6:
=====================

  Description: "Modifiers"
  Output Path: "api/modifiers.md"
  Overwrite: true

    File Source
    ===========
    Source Paths: ["./src/Modifier", "./src/SourceModifierInterface.php"]
    File Pattern: "*.php"
    Ignore Unreadable Dirs: false
    Show Tree View: true

Refactor JsonConfigParser with modular plugin architecture

This PR refactors the JsonConfigParser into a more modular, extensible plugin-based architecture. The changes provide a foundation for handling diverse configuration needs through specialized plugins rather than a monolithic parser.

Benefits

  • Extensibility: New configuration sections can be added without modifying existing code
  • Separation of concerns: Each plugin handles a specific part of the configuration
  • Type safety: Registry system provides type-safe access to configuration items

   - Replace monolithic JsonConfigParser with modular ConfigParser
   - Implement plugin-based configuration parsing system
   - Create DocumentsParserPlugin for document configuration handling
   - Establish proper interfaces for parsers and plugins
   - Update loaders to work with the new parser architecture
   - Move related classes to appropriate namespaces

2. Add experimental Display command for configuration visualization
   - Implement DisplayCommand to show configuration in human-readable format
   - Create renderer classes for visualizing documents, sources, and modifiers
   - Add styling utilities for terminal output formatting
@butschster butschster changed the title 1. Refactor JsonConfigParser with modular plugin architecture - Replace monolithic JsonConfigParser with modular ConfigParser - Implement plugin-based configuration parsing system - Create DocumentsParserPlugin for document configuration handling - Establish proper interfaces for parsers and plugins - Update loaders to work with the new parser architecture - Move related classes to appropriate namespaces Refactor JsonConfigParser with modular plugin architecture Mar 14, 2025
@butschster butschster added the enhancement New feature or request label Mar 14, 2025
- Add ConsoleLogger that integrates with Symfony Console's OutputInterface
- Respect console verbosity levels for different log priorities
@butschster butschster self-assigned this Mar 15, 2025
@butschster butschster merged commit 2aedb57 into main Mar 15, 2025
8 checks passed
@butschster butschster deleted the feature/json-parser-plugin-system branch March 15, 2025 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants