Giter Site home page Giter Site logo

haruncpi / laravel-log-reader Goto Github PK

View Code? Open in Web Editor NEW
374.0 6.0 38.0 279 KB

A simple and beautiful laravel log reader

Home Page: https://laravelarticle.com/laravel-log-reader

laravel laravel-log-reader laravel-package log-reader log-viewer laravel-log-viewer

laravel-log-reader's Introduction

laravel-log-reader's People

Contributors

haruncpi 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

laravel-log-reader's Issues

No logs appear on the panel

so when I get to the url, everything is fine except that I have no logs at all. here's the layout of logs and proof that they exist

here is logging details

<?php

use Monolog\Handler\StreamHandler;

return [

    /*
    |--------------------------------------------------------------------------
    | Default Log Channel
    |--------------------------------------------------------------------------
    |
    | This option defines the default log channel that gets used when writing
    | messages to the logs. The name specified in this option should match
    | one of the channels defined in the "channels" configuration array.
    |
    */

    'default' => env('LOG_CHANNEL', 'stack'),

    /*
    |--------------------------------------------------------------------------
    | Log Channels
    |--------------------------------------------------------------------------
    |
    | Here you may configure the log channels for your application. Out of
    | the box, Laravel uses the Monolog PHP logging library. This gives
    | you a variety of powerful log handlers / formatters to utilize.
    |
    | Available Drivers: "single", "daily", "slack", "syslog",
    |                    "errorlog", "monolog",
    |                    "custom", "stack"
    |
    */

    'channels' => [
        'stack' => [
            'driver' => 'stack',
            'channels' => ['daily', 'syslog', 'errorlog'],
        ],

        'single' => [
            'driver' => 'single',
            'path' => storage_path('logs/laravel.log'),
            'level' => 'debug',
        ],

        'daily' => [
            'driver' => 'daily',
            'path' => storage_path('logs/' . php_sapi_name() . '/laravel.log'),
            'level' => 'debug',
            'days' => 7,
        ],

        'slack' => [
            'driver' => 'slack',
            'url' => env('LOG_SLACK_WEBHOOK_URL'),
            'username' => 'Laravel Log',
            'emoji' => ':boom:',
            'level' => 'critical',
        ],

        'stderr' => [
            'driver' => 'monolog',
            'handler' => StreamHandler::class,
            'with' => [
                'stream' => 'php://stderr',
            ],
        ],

        'syslog' => [
            'driver' => 'syslog',
            'level' => 'error',
        ],

        'errorlog' => [
            'driver' => 'errorlog',
            'level' => 'error',
        ],
    ],

];

Class 'App\Http\Controllers\Controller' not found

<?php

 

namespace Haruncpi\LaravelLogReader\Controllers;

 

use App\Http\Controllers\Controller;

use Haruncpi\LaravelLogReader\LaravelLogReader;

use Illuminate\Http\Request;

use Illuminate\Support\Facades\File;

 

class LogReaderController extends Controller

That is probably because the package doesn't respect custom namespace. Can we add support for that?

htmlspecialchars error

Error message:htmlspecialchars() expects parameter 1 to be string, array given

it happened at bootstrap-4/dashboard.blade.php:23
"{{ $item['name'] }}"

I‘m using PHP 7.3, Laravel 7.

Laravel 8 throw an error

the package depend on user model which is located in past version in app folder but not the directory is changed we need to edit the
user-activity.php
'model' => [
'user' => "App\Models\User"
],

and
vendor\haruncpi\laravel-user-activity\src\Controllers\ActivityController.php

use App\Models\User;
private $userInstance = "\App\Models\User";

JS error when viewing log-reader page

image
There is a JS error, specifically angular-js error when visiting the log-reader page

image
There logging channel is set to already set to daily, as you can view in the screenshot above it already produced a daily log report

Is there anything that I missed during the package installation?

Customizeable views

In order for package to be more flexible and wider used, ability to publish and customize blade templates is a must
e.g. php artisan vendor:publish --provider="Haruncpi\LaravelLogReader\ServiceProvider" --tag="views"

[BUG] won't read custom log names

If you change log file names in config/logging.php then this package won't be able to read the files.

env

LOG_CHANNEL=daily

logging.php

'daily' => [
  'driver' => 'daily',
  'path' => storage_path('logs/whatEver.log'),
  'level' => 'debug',
  'days' => 14,
],

Unable to write to log file

This may be more of a Laravel issue, but I'm getting an error:
The stream or file "/var/app/current/storage/logs/laravel-2021-05-18.log" could not be opened in append mode: failed to open stream: Permission denied
Instead of the daily log file being created under the web user, it's being created under root user:

drwxrwxrwx 2 webapp webapp 4.0K May 18 16:12 .
drwxrwxrwx 5 webapp webapp 4.0K May 18 16:08 ..
-rwxrwxrwx 1 webapp webapp 14 May 18 16:08 .gitignore
-rw-r--r-- 1 root root 66K May 18 16:24 laravel-2021-05-18.log
-rw-r--r-- 1 webapp webapp 0 May 18 16:11 laravel.log

Is there any way to get the file to be created under webapp like all the other files?

No logs appear on the panel with error in logs

There is nothin on the panel and Sentry throws an issue

ErrorException
Notice: Undefined offset: 0
route | Haruncpi\LaravelLogReader\Controllers\LogReaderController@getLogs
public/index.php at line 54

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);

sql.query | select * from `users` where `id` = ? limit 1

url http://homestead.test/admin/api/log-reader

Package customization error

Hello, thanks for the great package.

After publishing the package with command
php artisan vendor:publish --provider="Haruncpi\LaravelLogReader\ServiceProvider" --tag="config"

and running
composer dump-autoload

The following error generated:

> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

In UrlGenerator.php line 120:
Argument 2 passed to Illuminate\Routing\UrlGenerator::__construct() must be an instance of Illuminate\Http\Request, null given, called in <Laravel-rout-path>\vendor\laravel\framework\src\Illuminate\Routing\RoutingServiceProvider.php on line 68

Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

The full error log is the following:

[2020-02-06 20:52:25] laravel.EMERGENCY: Unable to create configured logger. Using emergency logger. {"exception":"[object] (InvalidArgumentException(code: 0): Log [] is not defined. at [--Laravel-rout-path--]\\vendor\\laravel\\framework\\src\\Illuminate\\Log\\LogManager.php:192)
[stacktrace]
#0 [--Laravel-rout-path--]\\vendor\\laravel\\framework\\src\\Illuminate\\Log\\LogManager.php(118): Illuminate\\Log\\LogManager->resolve(NULL)
#1 [--Laravel-rout-path--]\\vendor\\laravel\\framework\\src\\Illuminate\\Log\\LogManager.php(98): Illuminate\\Log\\LogManager->get(NULL)
#2 [--Laravel-rout-path--]\\vendor\\laravel\\framework\\src\\Illuminate\\Log\\LogManager.php(547): Illuminate\\Log\\LogManager->driver()
#3 [--Laravel-rout-path--]\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Exceptions\\Handler.php(121): Illuminate\\Log\\LogManager->error('Argument 2 pass...', Array)
#4 [--Laravel-rout-path--]\\app\\Exceptions\\Handler.php(37): Illuminate\\Foundation\\Exceptions\\Handler->report(Object(Symfony\\Component\\Debug\\Exception\\FatalThrowableError))
#5 [--Laravel-rout-path--]\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Console\\Kernel.php(376): App\\Exceptions\\Handler->report(Object(Symfony\\Component\\Debug\\Exception\\FatalThrowableError))
#6 [--Laravel-rout-path--]\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Console\\Kernel.php(141): Illuminate\\Foundation\\Console\\Kernel->reportException(Object(Symfony\\Component\\Debug\\Exception\\FatalThrowableError))
#7 [--Laravel-rout-path--]\\artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#8 {main}
"} 
[2020-02-06 20:52:25] laravel.ERROR: Argument 2 passed to Illuminate\Routing\UrlGenerator::__construct() must be an instance of Illuminate\Http\Request, null given, called in [--Laravel-rout-path--]\vendor\laravel\framework\src\Illuminate\Routing\RoutingServiceProvider.php on line 68 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Argument 2 passed to Illuminate\\Routing\\UrlGenerator::__construct() must be an instance of Illuminate\\Http\\Request, null given, called in [--Laravel-rout-path--]\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\RoutingServiceProvider.php on line 68 at [--Laravel-rout-path--]\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\UrlGenerator.php:120)
[stacktrace]
#0 [--Laravel-rout-path--]\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\RoutingServiceProvider.php(68): Illuminate\\Routing\\UrlGenerator->__construct(Object(Illuminate\\Routing\\RouteCollection), NULL, NULL)
#1 [--Laravel-rout-path--]\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(799): Illuminate\\Routing\\RoutingServiceProvider->Illuminate\\Routing\\{closure}(Object(Illuminate\\Foundation\\Application), Array)
#2 [--Laravel-rout-path--]\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(681): Illuminate\\Container\\Container->build(Object(Closure))
#3 [--Laravel-rout-path--]\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(629): Illuminate\\Container\\Container->resolve('url', Array)
#4 [--Laravel-rout-path--]\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Application.php(776): Illuminate\\Container\\Container->make('url', Array)
#5 [--Laravel-rout-path--]\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\helpers.php(121): Illuminate\\Foundation\\Application->make('url', Array)
#6 [--Laravel-rout-path--]\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\helpers.php(932): app('Illuminate\\\\Cont...')
#7 [--Laravel-rout-path--]\\config\\laravel-log-reader.php(6): url('shopadmin')
#8 [--Laravel-rout-path--]\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Bootstrap\\LoadConfiguration.php(72): require('C:\\\\xampp\\\\htdocs...')
#9 [--Laravel-rout-path--]\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Bootstrap\\LoadConfiguration.php(39): Illuminate\\Foundation\\Bootstrap\\LoadConfiguration->loadConfigurationFiles(Object(Illuminate\\Foundation\\Application), Object(Illuminate\\Config\\Repository))
#10 [--Laravel-rout-path--]\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Application.php(219): Illuminate\\Foundation\\Bootstrap\\LoadConfiguration->bootstrap(Object(Illuminate\\Foundation\\Application))
#11 [--Laravel-rout-path--]\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Console\\Kernel.php(320): Illuminate\\Foundation\\Application->bootstrapWith(Array)
#12 [--Laravel-rout-path--]\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Console\\Kernel.php(129): Illuminate\\Foundation\\Console\\Kernel->bootstrap()
#13 [--Laravel-rout-path--]\\artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#14 {main}
"} 

The cause of the error is:
error line 7 [--Laravel-rout-path--]\config\laravel-log-reader.php(6): url('shopadmin')

Commenting out this 6th line from the \config\laravel-log-reader.php the issue is resolving.
The issue is known: laravel/framework#7671

The url() Laravel helper is not for use in the any_config.php files.

I suggest the change the package to do not use the url() helper function.
In the \config\laravel-log-reader.php by my opinion enough to use a simple string like '/admin' or '/shopadmin', or a rout name, and convert it to url in the view,

Index page breaks when changing API route

Great package, very useful!

One issue I found is if the API route changes in the config file, it no longer shows any logs. Seems to be due to hard coded routes in the index view

if (date !== '' && date !== undefined) {
    url = '{{url('/admin/api/log-reader')}}?date=' + date
        } else {
    url = '{{url('/admin/api/log-reader')}}'
}

Docs don't allow text copy.

The site where you host the docs ( https://laravelarticle.com ) has right click and Ctrl-C disabled with JavaScript.

This is 100% annoying on a development oriented site, especially documentation (can't even copy the "admin/log-reader" end of URL route), and 0% useful, as it's trivial for any developer (your target audience) to work around by disabling JavaScript (usually one click in the Ad Blocker we already have).

Please don't resort to tricks like this. Or at least move the documentation to a page without it, or to GitHub itself if you must do this for your other articles. But its not protecting anything, and just inspires "composer remove ..." and moving on.

(Most won't bother with letting you know about it, like this. I am trying to be helpful. And the package looks interesting and useful.)

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.