Coder Social home page Coder Social logo

saade / filament-laravel-log Goto Github PK

View Code? Open in Web Editor NEW
83.0 2.0 18.0 2.33 MB

Read Laravel logs from the Filament admin panel

Home Page: https://filamentphp.com/plugins/saade-laravel-log

License: MIT License

PHP 75.71% Blade 4.06% CSS 11.36% JavaScript 8.86%
filament laravel log log-viewer resource

filament-laravel-log's Introduction

Filament Laravel Log

Latest Version on Packagist Total Downloads

Banner

Features

  • Syntax highlighting
  • Light/ Dark mode
  • Quickly jump between start and end of the file
  • Refresh log contents
  • Clear log contents
  • Search multiple files in multiple directories
  • Ignored file patterns

Installation

You can install the package via composer:

composer require saade/filament-laravel-log:^3.0

Usage

Add the Saade\FilamentLaravelLog\FilamentLaravelLogPlugin to your panel config.

use Saade\FilamentLaravelLog\FilamentLaravelLogPlugin;

class AdminPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            // ...
            ->plugin(
                FilamentLaravelLogPlugin::make()
            );
    }
}

Configuration

Customizing the navigation item

FilamentLaravelLogPlugin::make()
    ->navigationGroup('System Tools')
    ->navigationLabel('Logs')
    ->navigationIcon('heroicon-o-bug-ant')
    ->navigationSort(1)
    ->slug('logs')

Customizing the log search

FilamentLaravelLogPlugin::make()
  ->logDirs([
      storage_path('logs'),     // The default value
  ])
  ->excludedFilesPatterns([
      '*2023*'
  ])

Authorization

If you would like to prevent certain users from accessing the logs page, you should add a authorize callback in the FilamentLaravelLogPlugin chain.

FilamentLaravelLogPlugin::make()
  ->authorize(
      fn () => auth()->user()->isAdmin()
  )

Customizing the log page

To customize the log page, you can extend the Saade\FilamentLaravelLog\Pages\ViewLog page and override its methods.

use Saade\FilamentLaravelLog\Pages\ViewLog as BaseViewLog;

class ViewLog extends BaseViewLog
{
    // Your implementation
}
use App\Filament\Pages\ViewLog;

FilamentLaravelLogPlugin::make()
  ->viewLog(ViewLog::class)

Customizing the editor appearance

Publish the config file:

php artisan vendor:publish --tag="log-config"

This is the contents of the published config file:

<?php

return [
    /**
     * Maximum amount of lines that editor will render.
     */
    'maxLines' => 50,

    /**
     * Minimum amount of lines that editor will render.
     */
    'minLines' => 10,

    /**
     * Editor font size.
     */
    'fontSize' => 12
];

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Sponsor Saade

filament-laravel-log's People

Contributors

albertofuentes avatar amiraghaee avatar awcodes avatar dependabot[bot] avatar gergo85 avatar github-actions[bot] avatar juliomotol avatar malzariey avatar mileswucode avatar saade avatar sitenzo avatar ysfkaya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

filament-laravel-log's Issues

Exception: Target class [hash] does not exist

Hi,

Thanks for creating this plugin, I believe it's very useful!

One thing I discovered is when I add this callback for the authorize() method an Exception is thrown:

        ->authorize(
            fn () => auth()->user()->hasRole('super_admin')
        ),

This is the Exception:
image

Any clues on why this is happening?

Facade is triggering errors when updating IDE Helper files

I believe the Facade \Saade\FilamentLaravelLog\Facades\FilamentLaravelLog isn't set up correctly because composer complains about it every time when it updates files for my IDE Helper:

> @php artisan ide-helper:generate
Exception: Target class [filament-laravel-log] does not exist.
Skipping \Saade\FilamentLaravelLog\Facades\FilamentLaravelLog.
Exception: Target class [filament-laravel-log] does not exist.
Skipping \Saade\FilamentLaravelLog\Facades\FilamentLaravelLog.

Is the Facade actually needed or useful?

Plugin [filament-laravel-log] is not registered for panel [admin]. Can not add this to custom admin panel

I want this plugin only on developer admin panel. But I am getting this exception on adding it to developer admin panel.

Plugin [filament-laravel-log] is not registered for panel [admin].

To fix this I need to also add this with default admin panel, then I can use it to other admin panel, like in my case developer admin panel.

Kindly fix this, so that we can use this separately to custom admin panel page.

Default admin panel

return $panel
            ->default()
            ->id('admin')
            ->path('admin')
.....
->plugins([
                FilamentLaravelLogPlugin::make()
                    ->navigationGroup('System Tools')
                    ->navigationLabel('Logs')
                    ->navigationIcon('heroicon-o-bug-ant')
                    ->navigationSort(1)
                    ->slug('logs')
            ]);

Custom admin panel

 return $panel
            ->id('developer')
            ->path('developer')
.....
->plugins([
                FilamentLaravelLogPlugin::make()
                    ->navigationGroup('System Tools')
                    ->navigationLabel('Logs')
                    ->navigationIcon('heroicon-o-bug-ant')
                    ->navigationSort(1)
                    ->slug('logs')
            ]);

Publish config file command doesn't work

Hello,

Thanks for your package, it's really neat!

There is an error in the readme regarding the publish file command though:

php artisan vendor:publish --tag="filament-laravel-log-config"

This returned the following error message:
No publishable resources for tag [filament-laravel-log-config].

The command to publish assets for me were the following:

  • php artisan vendor:publish --tag="log-config"
  • php artisan vendor:publish --tag="log-translations"
  • php artisan vendor:publish --tag="log-views"

I had to look for the proper one by using the generic 'vendor:publish' command, as you can see below:

Capture d’écran 2022-06-02 à 10 56 53

logDirs([]) not working.

Hello, this is a very nice package.

However, I am unable to set custom log directories using the given method. It just falls back to the default "logs".

Has anyone else faced the same issue before?

image

Basically, this is how I have implemented it. Each of the two directories has one log file. Neither is seen.

In authorization auth()->user() returns null

Maybe I'm missing something, but here goes.

According to the documentation, I could do something like this:

FilamentLaravelLogPlugin::make()
  ->authorize(
      fn () => auth()->user()->isAdmin()
  )

However, the return from auth()->user() is always null. Apparently, in the life cycle, the providers are analyzed before the laravel framework retrieves the authenticated user's data.

Therefore, there is no way to do any checking there, since the user is not yet available.

Am I forgetting something or is there a bug here?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.