Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Log Viewer Bundle Laravel Package

danilovl/log-viewer-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require danilovl/log-viewer-bundle
    

    Add to config/bundles.php and run php bin/console assets:install.

  2. Basic Configuration: Create config/packages/danilovl_log_viewer.yaml with minimal settings:

    danilovl_log_viewer:
        sources:
            dirs: ['%kernel.logs_dir%']
    
  3. First Use Case: Access /danilovl/log-viewer to view logs. Use the File Reader to inspect large log files incrementally.


Implementation Patterns

Core Workflows

  1. Log Discovery & Filtering:

    • Configure sources.dirs to include log directories (e.g., %kernel.logs_dir%).
    • Use sources.ignore to exclude files (e.g., ['cache.log']).
    • Leverage Global Search (/danilovl/log-viewer/search) for cross-file queries with regex support.
  2. Real-Time Monitoring:

    • Enable Live Logs in config:
      live_log_page:
          enabled: true
          interval: '3 sec'
          levels: ['error', 'critical']
      
    • Monitor multiple files simultaneously via the Live Multi-source View modal.
  3. Remote Logs:

    • Configure SSH/SFTP access:
      remote_hosts:
          - name: 'prod_server'
            type: 'ssh'
            host: '1.2.3.4'
            user: 'deploy'
            ssh_key: '%kernel.project_dir%/config/ssh/id_rsa'
            dirs: ['/var/log']
      
  4. Parser Optimization:

    • Enable Go-based parser for large files:
      parser:
          go_enabled: true
          overrides:
              '/var/log/nginx/access.log': 'nginx_access'
      
  5. API Integration:

    • Use the REST API for custom dashboards:
      GET /danilovl/log-viewer/api/logs?file=/var/log/app.log&limit=50
      
    • Fetch log statistics:
      GET /danilovl/log-viewer/api/statistics?file=/var/log/app.log
      
  6. AI-Assisted Debugging:

    • Configure AI chats in ai.chats and enable for error levels:
      ai:
          button_levels: ['error', 'critical']
          chats:
              - { name: 'ChatGPT', url: 'https://chatgpt.com/?q={prompt}' }
      

Integration Tips

  • Symfony Notifier: Use the danilovl:log-viewer:watch command for real-time alerts:
    php bin/console danilovl:log-viewer:watch --interval=5 --limit=100
    
  • Dark/Light Mode: Respects browser/system preferences by default. Override via CSS variables.
  • Localization: Supports 10+ languages. Set in Symfony’s framework.default_locale.

Gotchas and Tips

Pitfalls

  1. File Permissions:

    • allow_delete/allow_download require web server write/read access to log files.
    • Remote logs (ssh/sftp) need ssh2 PHP extension and valid credentials.
  2. Go Parser Dependency:

    • If go_enabled: true, ensure the binary at go_binary_path exists and is executable.
    • Debug missing binaries with:
      php bin/console danilovl:log-viewer:debug
      
  3. Regex Performance:

    • Complex regex in Global Search may lag with large files. Use max_file_size to limit parsing:
      sources:
          max_file_size: 10485760 # 10MB
      
  4. Caching Quirks:

    • cache.parser_detect_enabled caches parser detection but may stale if log formats change.
    • Clear cache with:
      php bin/console cache:clear
      
  5. Live Logs Latency:

    • High live_log_page.interval values (e.g., 1 sec) increase server load. Test with 3-5 sec first.

Debugging

  • Log Parser Errors:

    • Check Symfony logs (var/log/dev.log) for parser failures.
    • Override parsers explicitly in parser.overrides to bypass auto-detection.
  • API Issues:

    • Validate API responses with:
      GET /danilovl/log-viewer/api/health
      
    • Common HTTP 500 causes: Missing files or invalid parser configs.
  • Vue SPA Errors:

    • Clear browser cache or rebuild assets:
      yarn build
      php bin/console assets:install
      

Extension Points

  1. Custom Parsers:

    • Extend Danilovl\LogViewerBundle\Parser\ParserInterface for new log formats (e.g., custom app logs).
    • Register via parser.overrides or dynamically in a service.
  2. Notifier Rules:

    • Add dynamic rules via a Symfony event listener for danilovl.log_viewer.notification events.
  3. UI Customization:

    • Override Vue components in templates/bundles/logviewer/ to modify the SPA.
    • Extend CSS via assets/css/log-viewer.css.
  4. API Extensions:

    • Create custom controllers extending Danilovl\LogViewerBundle\Controller\ApiController for additional endpoints.
  5. Bookmark Sync:

    • Replace localStorage bookmarks with a database-backed solution by extending the BookmarkManager service.

Pro Tips

  • Monitor Critical Paths: Combine live_log_page.levels with notifier.rules to alert on errors and stream them in real-time:

    live_log_page:
        levels: ['error', 'critical']
    notifier:
        rules:
            - levels: ['error', 'critical']
              channels: ['chat/slack']
    
  • Offload Heavy Parsing: Use the Go parser for production logs and disable it locally:

    parser:
        go_enabled: '%kernel.environment% === "prod"'
    
  • Bookmark Workflows: Train ops teams to use Bookmarks for recurring issues (e.g., "star" errors from a specific endpoint).

  • Dark Mode Optimization: Prefer prefers-color-scheme over manual toggles for accessibility:

    :root {
        --log-viewer-bg: #121212;
    }
    @media (prefers-color-scheme: light) {
        :root {
            --log-viewer-bg: #ffffff;
        }
    }
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codraw/entity-migrator
codraw/doctrine-extra
codraw/aws-tool-kit
codraw/validator
codraw/workflow
codraw/open-api
codraw/cron-job
codraw/process
codraw/log
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony