furybee/logger-ui

The Laravel Logger UI.

0.3.1 2021-12-06 10:41 UTC

This package is auto-updated.

Last update: 2024-05-05 20:20:14 UTC


README

logger-ui-main

Installing The Logger UI Dashboard

This package provides a beautiful dashboard through your application that allows you to send logs to a database and show them. The Logger UI dashboard package can be installed in your project using Composer:

composer require furybee/logger-ui

After installing Logger UI, you may publish its assets using the logger-ui:install Artisan command.

php artisan logger-ui:install

You should also run the migrate command in order to create the table needed to store Logger UI's data:

Note : if you are using SingleStore, add --singlestore=on option.

php artisan logger-ui:migrate

Setup Logger UI as default channel

In your config/logging.php file, add the following channel:

'logger-ui' => [
    'driver' => 'custom',
    'path' => DBHandler::class,
    'via' => DBLogger::class,
    'level' => 'debug',
],

Then edit your LOG_CHANNEL env key for logger-ui:

LOG_CHANNEL=logger-ui

Dashboard Authorization

Logger UI exposes a dashboard at the /logger-ui URI. Within your app/Providers/LoggerUiServiceProvider.php file, there is a gate method that controls access to the Logger UI dashboard. By default, all visitors are restricted. You should modify this gate as needed to grant access to your Logger UI dashboard:

/**
 * Register the Logger UI gate.
 *
 * This gate determines who can access Logger UI in non-local environments.
 *
 * @return void
 */
protected function gate()
{
    Gate::define('viewLoggerUI', function ($user = null) {
        return in_array(optional($user)->email, [
            'hello@sebastienfontaine.me',
        ]);
    });
}

Upgrading Logger UI

When upgrading to a new version of Logger UI, you should re-publish Logger UI's assets:

php artisan logger-ui:publish

To keep the assets up-to-date and avoid issues in future updates, you may add the logger-ui:publish command to the post-update-cmd scripts in your application's composer.json file:

{
  "scripts": {
    "post-update-cmd": ["@php artisan logger-ui:publish --ansi"]
  }
}

Customization

If you have not published Logger UI's configuration file, you may do so using the vendor:publish Artisan command:

php artisan vendor:publish --tag=logger-ui-config

Once the configuration file has been published, you may edit Logger UI's middleware, queue name or database by tweaking the configuration options within this file.

Database

If needed, you may update DB Connection and the Table where logger-ui will store the data.

'db' => [
    'connection' => env('DB_CONNECTION', null),
    'table' => env('DB_LOGGER_UI_TABLE', 'logger_ui_entries')
],

Queue

If you are using a Queue Driver different of sync, you may update the Queue Configuraion. The Log Data will be sent by a Job. Otherwise, it will be sent in the request lifecycle.

'queue' => [
    'active' => false,
    'name' => env('DB_LOGGER_UI_QUEUE_NAME', 'default'),
],

Middleware

If needed, you can customize the middleware stack used by Logger UI routes by updating your config/logger-ui.php file.

/*
|--------------------------------------------------------------------------
| Logger UI Route Middleware
|--------------------------------------------------------------------------
|
| These middleware will be assigned to every Logger UI route - giving you
| the chance to add your own middleware to this list or change any of
| the existing middleware. Or, you can simply stick with this list.
|
*/

'middleware' => [
    'web',
    EnsureUserIsAuthorized::class,
],

Inspiration