rap2hpoutre / laravel-log-viewer Goto Github PK
View Code? Open in Web Editor NEW:dromedary_camel: Laravel log viewer
License: MIT License
:dromedary_camel: Laravel log viewer
License: MIT License
It's a great feature to delete logs you no longer need, but for log files that will be recreated (Such as lumen.log or laravel.log), wouldn't it be best to just empty it?
This feature is completely freezing up my browser every time when I have alot of data. until this becomes a setting could you give me a pointer as to where to disable it in the code?
I have a very big (2,5GB) log file in my Laravel application because it used a single log file in the past. I've installed the package, but I'm getting a memory exhausted error.
[2015-03-23 09:08:50] live.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Allowed memory size of 134217728 bytes exhausted (tried to allocate 2658702094 bytes)'
The command composer require rap2hpoutre/laravel-log-viewer
should be used in place of composer require rap2hpoutre/laravel-log-viewer:0.2.*
as the former will resolve to the lastest stable version with any patch version e.g. composer require rap2hpoutre/laravel-log-viewer:~0.2
This will save having to update the README's installation instructions on every new release.
Now we have a preg_match()
that extract all things to $current
array
preg_match('/^\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})\].*?\.' . $level_key . ': (.*?)( in .*?:[0-9]+)?$/', $h[$i], $current);
with this results
$log[] = array(
'level' => $level_value,
'level_class' => self::$levels_classes[$level_value],
'level_img' => self::$levels_imgs[$level_value],
'date' => $current[1],
'text' => $current[2],
'in_file' => isset($current[4]) ? $current[4] : null,
'stack' => preg_replace("/^\n*/", '', $log_data[$i])
);
And all okay, but if i adding processors:
// processor, adding URI, IP address etc. to the log
$monolog->pushProcessor(new Monolog\Processor\WebProcessor);
// processor, memory usage
$monolog->pushProcessor(new Monolog\Processor\MemoryUsageProcessor);
In our log we now have two new items in message ex:
Logger message! [] {"memory_usage":"19,25 MB","url":"/it/dashboard/clients/clients","ip":"95.254.111.11","http_method":"GET","server":"www.server.com","referrer":null,"unique_id":"Vzs4x1BYW8cBBEH123gAAABL"}
What if we add something to preg_match()
for capture log extra and take it separately?
ex:
preg_match('/^\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})\].*?\.' . $level_key . ': (.*?) ( in .*?:[0-9]+)? (\{.*\}?)$/', $h[$i], $current);
I tryed but need help from someone more expert than me.
Log message with stack trace are different?
How put an optional reg_exp in case if trace/in_file are not present?
If this thing are interesting i can investigate and make a pr.
I am getting the above Error.
I placed the Class LaravelLogViewer to App/Backend
<?php
namespace App\Http\Controllers\Backend;
use Illuminate\Support\Facades\View;
class LaravelLogViewer extends \Illuminate\Routing\Controller
{
public function index()
{
if (\Input::get('l')) {
LaravelLogViewer::setFile(base64_decode(\Input::get('l')));
}
$logs = LaravelLogViewer::all();
View::addNamespace('laravel-log-viewer', __DIR__.'/../views');
return View::make('laravel-log-viewer::log', [
'logs' => $logs,
'files' => LaravelLogViewer::getFiles(true),
'current_file' => LaravelLogViewer::getFileName()
]);
}
}
My Route:
Route::get('logs', 'Backend\LaravelLogViewer@index');
Do i need to add any ServiceProvider or something like this ?
in src/controllers/LogViewerController.php, line 7
The class
Illuminate\Support\Facades\Input
is declared but never used. You should remove theuse
statement.
namespace Rap2hpoutre\LaravelLogViewer;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\Response;
Posted from SensioLabsInsight
This exception is thrown if no log file exists yet.
It should be a quick fix, this is the spot
https://github.com/rap2hpoutre/laravel-log-viewer/blob/master/src/Rap2hpoutre/LaravelLogViewer/LaravelLogViewer.php#L53
If you'd like I can submit a pull request.
PS: this log viewer is really cool!
It would be useful a new feature for removing log lines.
exception 'ErrorException' with message 'preg_match_all() expects parameter 2 to be string, array given'
in /var/www/html/app/public/vendor/rap2hpoutre/laravel-log-viewer/src/Rap2hpoutre/LaravelLogViewer/LaravelLogViewer.php:73
Thank you. (y)
Hi, I use this code to save all errors to DB. Maybe create reader for that ?
Log::listen(function($level, $message, $context) {
$apiName = php_sapi_name();
$date = new DateTime;
Queue::push(function() use ($level, $message, $context, $apiName, $date) {
DB::insert("INSERT INTO logs (php_sapi_name, level, message, context, created_at) VALUES (?, ?, ?, ?, ?)", array(
$apiName,
$level,
$message,
json_encode($context),
$date
));
});
});
You don't need to register your own views namespace. Just use this in your controller:
return View::file(__DIR__.'/../views/log.blade.php', [...]);
If the reason it was added is to support L4, I have to disagree. Taylor has said many times that if you need to support L4 and L5, they should live in separate branches.
Adding a service provider complicates this package for no reason. You usually don't want this in production, so I loaded this package in composer's require-dev
array, and have this in my routes file:
if (config('app.debug'))
{
get('logs', '\Rap2hpoutre\LaravelLogViewer\LogViewerController@index');
}
There's no reason you should now have to conditionally load a service provider.
The controller class has two uses of request as a function so the controller is failing in Laravel 4. The change was introduced in 02c6ddd
Hi !
I use laravel 4.2
I have this error message when i want going on the log page
Class 'Rap2hpoutre\LaravelLogViewer\LaravelLogViewerServiceProvider::class' not found
thx !
how can i use custom view ? Because these cdns that used in your view is so slow in my country (china), and i want to change direction and font-family to make my logs looks nicer (arabic letters).
we need to fix the controller b/c Redirect is not working
clicking delete gives:
"message": "Class redirect does not exist",
"exception": "ReflectionException",
cheers max
Got this error after following the installation instruction for Lumen:
Class App\Http\Controllers\Rap2hpoutre\LaravelLogViewer\LogViewerController does not exist
FYI, the route's settings file in Lumen 5.3 is on: routes/web.php
As it is already mentioned here in #68 (comment) to clear the cache.
Damn I spend at least an hour to find the cause of that 'hint path' error. Will be really helpful for future who face same problems like me.
Thanks , Great Log Viewer
When looking at errors I think it would be easier to make the complete row or at least the error itself clickable instead of just the magnifier glass on the right.
Reason is because I'm too lazy to move the mouse to the right every time, do others agree with this?
Hi,
When I add the code Route::get('logs', 'Rap2hpoutre\LaravelLogViewer\LogViewerController@index');
to routes.php, and then visit http://myapp/logs
, it shows
Class App\Http\Controllers\Rap2hpoutre\LaravelLogViewer\LogViewerController does not exist
How can I fix it? Thanks!
The second argument for Log::info() (or any other log) takes the context array. Would you be able to manage to implement a more human readable form instead of a json representation of the array?
I currently add a new line to my message so it drops the context to a new line. This way it will be caught by $log['stack']
and expanded when the search button is pressed.
Instead of loading an entire logfile in one go, can we use AJAX to fetch just the rows that are needed? Datatable is really good at this, and it is surprisingly easy to do with a package to handle the server side, such as https://github.com/yajra/laravel-datatables
Hello,
It seems that the log level 'emergency' not exists.
ErrorException in LaravelLogViewer.php line 104:
Undefined index: emergency
Some times I find it useful to set a custom context when logging and it'd be awesome to see this shown in the table.
When I do this it allows me to see where particular logging is coming form in my apps, I know it's not something that everyone may think is essential but to me this would be a great help. I believe it should be pretty darn easy to get setup too.
I think I'll submit a patch for this later tonight if I'm able to get it working.
Im a newbie with laravel, but did all as in the README of this package and when I go to http://myapp/logs I get this error:
InvalidArgumentException in compiled.php line 12896: No hint path defined for [laravel-log-viewer]
Any ideas on why this happens?
Thanks.
Sometimes the log/stacktrace is pretty wide, and when I expand it, I cannot collapse it without scrolling sideways, because the button moves out of the visible area (and it's on a 1920px wide screen)
I suggest wrapping the stack trace in a separate element and overflow:auto it, so the main layout doesn't expand more than needed.
Hello, good morning.
After trying a few different methods I found a way to make the package use my own View, adding this to routes.php in Laravel 4.2
\View::addNamespace('laravel-log-viewer', app_path().'/views/packages/laravel-log-viewer/');
I think it should be appropriate to add this information to Readme, I don't dare because I'm not sure this is the 100% best method.
Thanks.
I often get errors in view files. Such as this one:
storage/framework/views/43b5cdd1d840a31e686df15ac113ab92:45
.
It would be just great to be able to click the filename and see the content - and match the line with blade
file
or at least somehow get the filename of the original blade
file.
Now I am forced to
blade
fileGreat repo, BTW!!
Thx
Hello,
Thanks for writing such a great tool. I'm trying to install it on Lumen and I'm running into issues. When I run ..
composer require rap2hpoutre/laravel-log-viewer
.. a rap2hpoutre folder is added to my vendor folder. And attempting to access the controller throws an error:
ReflectionException in Container.php line 749: Class App\Http\Controllers\Rap2hpoutre\LaravelLogViewer\LogViewerController does not exist
Any help would be much appreciated.
production.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Allowed memory size of 134217728 bytes exhausted (tried to allocate 153967073 bytes)' in /srv/www/someline.com/someline/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:34
I think the problem is underlying that the log files are large in size, if you load them all in one time, it will not able to display.
Could you advice some solutions?
On Laravel 5, Blade Tag {{ .. }}
was changed to {!! .. !!}
.
https://github.com/rap2hpoutre/laravel-log-viewer/blob/master/src/views/log.blade.php#L82
After the suggestion here:
The idea is to have separate views - one for the layout, i.e. the page wrapper, and one for the content - the tables. Anyone wanting to put the content into their own layout templates in their own application, will need to split the view like this as the first step, so it will help a lot to build it like this in the first place.
Needs htmlentities() (or similar) wrapped around at least the output of $log['stack']... otherwise "bad things" happen... :-)
in src/controllers/LogViewerController.php
This file contains 3 classes. Keeping only one class per file is a standard in the PHP community, since it promotes interoperability and maintainability.
Posted from SensioLabsInsight
You could use cookies or local storage to remember entry count per page.
I have that mistake, and try several ways and nothing
I often use logs to debug the application and it would be useful if you can select row as solved or hide it from log viewing.
What do you think, guys?
This log viewer will be viewing some massive files, which thousands of entries. The table that is rendered has thousands of rows, and many more table cells.
All this is padded out with white space from the view, which can add megabytes to a page, and contribute to the browser crashing. Can this white space between elements, and around data in table cells, be stripped out? I'm not sure how to suggest this is done, while preserving the readability of the source view, but there must be a way.
Sometimes it's easier to view log file a notepad, for searching, etc. Maybe it would be useful, if I could download a log file with a click :)
What do you think about this feature?
It would be awesome if the page would automatically update when there are new items to show.
Ideally, this would be done with sockets. I don't have a lot of experience with sockets in PHP, but I've found it's not nearly as easy as say, Node and socket.io
.
I'm really not sure how viable this is in pure PHP (i.e. I don't know that you can really watch for file changes in realtime with PHP), but it would be a super useful feature! Definitely possible and not terrible difficult with Node, but that'd require another dependency.
Just wanted to throw this out there and see if anyone else had any ideas.
Getting this:
ErrorException in Filesystem.php line 109:
file_put_contents(/8414948cc128b33a8c074d83101ba69d62cc89a5.php): failed to open stream: Permission denied
/storage/logs/laravel.log has 777 permissions.
Any idea?
Thanks.
It would be very useful to see the rendered html message in log when we are debugging e-mail workflow using "log" driver.
I've managed to do that modifying log.blade.php @line 87 to be like this:
@if(!strpos($log['stack'],'Content-Transfer-Encoding'))
<div class="stack" id="stack{{{$key}}}" style="display: none; white-space: pre-wrap;">{{{ trim( $log['stack'] ) }}}</div>
@else
<div class="stack" id="stack{{{$key}}}" style="display: none;">{!! preg_replace('/(Content-Transfer-Encoding[^\n]+)/', '$1<br><br>', $log['stack']) !!}</div>
@endif
It basically detects the last mail header and prints the unescaped html message, if the log entry is an e-mail.
It's a dirty hack and needs some cleanup, but worked pretty well for me. ;)
May I submit a PR?
I get Class App\Http\Controllers\\Rap2hpoutre\LaravelLogViewer\LogViewerController does not exist
when using this with Lumen
It would be great to have config file with ability to use own layout file and integrate it seamlessly in backend application.
How is it possible / is it even possible to modify the look (e.g include the logviewer in the own website design)?
I change blade's default delimiters in my laravel project, like so:
/*-------------------------------------------------------------------------
| Change default Blade delimiters
|------------------------------------------------------------------------*/
Blade::setContentTags('[[', ']]'); // for variables and all things Blade
Blade::setEscapedContentTags('[[#', '#]]'); // for escaped data
Which makes Laravel Log viewer not play well, I have to go and edit the views in the source to change all the delimiters.
Any way you can add a feature that detects what the current delimiters are and use those for the log view?
Sometimes i need to clean the content of the most recent LOG file - just to avoid confusion.
A button doing that would be a great idea
Hi, I have just discovered this package and love it. I was wondering what you'd think about adding additional information on rollover on links in the sidebar? I think the file size and the number of entries would be two valuable informations to have without having to click and load the file.
hi,
i get this error how can i fix this?
InvalidArgumentException in FileViewFinder.php line 112: No hint path defined for [laravel-log-viewer].
thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.