laravel / pail

Dive into your Laravel application's log files directly from the console. 🪣
MIT License
702 stars 20 forks source link

Support for Reading Custom Log Files (e.g., query.log) #37

Closed rupeshstha closed 2 months ago

rupeshstha commented 2 months ago

Feature Request

Currently, this package primarily supports reading logs from the default laravel.log file. However, many applications generate custom log files (e.g., query.log for database queries) that developers may need to monitor and analyze separately. This feature request proposes enhancing Pail to support reading and displaying entries from these custom log files alongside the default log.

Motivation

As developers managing applications with specific logging requirements, being able to integrate and manage custom log files within Pail directly would streamline our monitoring and debugging workflows. It eliminates the need for manual workarounds and allows for a more unified log management solution.

Proposed Solution

Configuration Enhancement: Introduce configuration options within Pail to specify additional log file paths or channels, such as query.log, error.log, etc.

Implementation Considerations

Compatibility: I thoroughly reviewed code base if this feature is accepted then, it seems like we also need to pass the channel reference from the LogManager to Log so i guess we also need to update laravel/framework

How i'm using right now

DB::listen(function ($query) {
    Event::dispatch(new Illuminate\Log\Events\MessageLogged("info", $query->sql, $query->bindings));

    File::append(
        path: storage_path('/logs/query.log'),
        data: $query->sql . ' [' . implode(', ', $query->bindings) . ']' . PHP_EOL
    );
});

Request for Feedback

I welcome feedback from maintainers and the community on this proposed feature. Your insights and suggestions will help refine the implementation and ensure its alignment with Laravel's ecosystem and best practices.

Thank you for considering this feature request. I look forward to discussing and contributing to its implementation.

driesvints commented 2 months ago

Thanks. Right now we don't have any plans on working this ourselves. You can always attempt a PR if you want 👍