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

Nova Error Logger Laravel Package

justbetter/nova-error-logger

Laravel Nova integration for justbetter/laravel-error-logger. Install via Composer and view logged application errors inside Nova. Versioning matches Nova major versions (v4 for Nova 4, v3 for Nova 3; older versions for earlier Nova releases).

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require justbetter/nova-error-logger
    

    Publish the config file (if needed):

    php artisan vendor:publish --provider="JustBetter\NovaErrorLogger\NovaErrorLoggerServiceProvider"
    
  2. First Use Case:

    • Ensure justbetter/laravel-error-logger is installed in your Laravel app (this package is an extension for Nova).
    • Register the Nova resource in NovaServiceProvider:
      use JustBetter\NovaErrorLogger\ErrorLogger;
      
      public function tools()
      {
          return [
              new ErrorLogger,
          ];
      }
      
    • Access the tool via Nova’s sidebar under "Error Logger".

Implementation Patterns

Core Workflows

  1. Error Logging Integration:

    • Errors logged via justbetter/laravel-error-logger (e.g., Log::error() or throw new \JustBetter\ErrorLogger\ErrorLoggerException) will auto-populate the Nova dashboard.
    • Use the ErrorLogger facade in your app:
      use JustBetter\ErrorLogger\Facades\ErrorLogger;
      
      ErrorLogger::log(new \Exception("Test error"));
      
  2. Nova Dashboard Usage:

    • Viewing Errors: Filter by status, severity, or time range.
    • Resolving Errors: Click an error to see details (stack trace, context, timestamps). Mark as resolved via the UI.
    • Exporting: Export logs as CSV/JSON for analysis.
  3. Customizing Log Display:

    • Override the default resource fields in app/Nova/ErrorLogger.php:
      public function fields(Request $request)
      {
          return [
              ID::make()->sortable(),
              Text::make('Message')->sortable(),
              Text::make('Stack Trace')->onlyOnDetail(),
              // Add custom fields from your error context
              Text::make('Custom Field', function ($error) {
                  return $error->context['custom_key'] ?? null;
              }),
          ];
      }
      
  4. Automated Alerts:

    • Use Nova’s Actions to trigger Slack/email alerts for critical errors:
      public function actions(Request $request)
      {
          return [
              (new AlertAction)->setButtonLabel('Notify Team'),
          ];
      }
      

Gotchas and Tips

Pitfalls

  1. Dependency Mismatch:

    • Ensure justbetter/laravel-error-logger is installed in your Laravel app. Nova’s tool is not a standalone logger.
    • Check compatibility with your Nova version (e.g., ^4.0 for Nova 4.x).
  2. Permission Issues:

    • Nova’s tool requires view error-logger permission. Assign via Nova’s Permissions tool:
      Nova::permissions([
          'view error-logger' => 'View error logs',
      ]);
      
  3. Performance:

    • Large error volumes may slow Nova. Use the perPage() method to limit results:
      public function indexQuery(Nova $nova, Request $request)
      {
          return parent::indexQuery($nova, $request)->paginate(50);
      }
      
  4. Context Data:

    • Errors logged without context (e.g., ErrorLogger::log(new Exception())) will lack metadata. Attach context explicitly:
      ErrorLogger::log(new Exception("Payment failed"), [
          'user_id' => auth()->id(),
          'amount' => $request->amount,
      ]);
      

Debugging Tips

  • Logs Not Appearing? Verify justbetter/laravel-error-logger is configured in config/error-logger.php and errors are being logged to the correct channel (e.g., error_logger). Check Laravel logs (storage/logs/laravel.log) for initialization errors.

  • Stack Trace Formatting: If stack traces are truncated, override the StackTrace field in the Nova resource:

    Textarea::make('Stack Trace')->onlyOnDetail()->asHtml(),
    

Extension Points

  1. Custom Error Types: Extend the base Error model to add fields:

    // app/Models/Error.php
    class Error extends \JustBetter\ErrorLogger\Models\Error
    {
        protected $casts = [
            'metadata' => 'array',
        ];
    }
    
  2. Nova Tool Branding: Customize the tool’s appearance in resources/js/tools/ErrorLogger/Tool.jsx (if you’ve published assets):

    <TitleBar title="Custom Error Tracker" />
    
  3. Webhook Integration: Use Nova’s Actions to POST error data to an external API:

    public function handle(Nova $nova, $error)
    {
        Http::post('https://your-api.com/webhooks', [
            'error' => $error->toArray(),
        ]);
    }
    
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.
nasirkhan/laravel-sharekit
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony