bankdev / logviewer
Laravel 4.2 log file viewer.
Requires
- php: >=5.3.7
- illuminate/filesystem: ~4.0
- illuminate/support: ~4.0
- psr/log: ~1.0
- symfony/finder: ~2.3
Requires (Dev)
- mockery/mockery: ~0.9
- phpunit/phpunit: ~4.0
This package is not auto-updated.
Last update: 2024-11-19 03:10:30 UTC
README
#Laravel 4.2 LogViewer
Easily view and delete Laravel 4's logs.
Inspiration from Fire Log for CodeIgniter by David Morrow and Larvel Log Viewer for Laravel 3 by Eric Barnes
Created and maintained by Micheal Mand. Copyright © 2013. Licensed under the MIT license.
#A note about Laravel 4.2
Laravel 4.2 applications log things differently than they used to. While this doesn't technically break LogViewer, LogViewer also doesn't know how to handle these changes. Here's a quick fix:
In your app/start/global.php
, line 34 change:
Log::useFiles(storage_path().'/logs/laravel.log');
to:
$logFile = 'log-'.php_sapi_name().'.txt'; OR $logFile = 'xxx.'.log; $logFile = 'xxx'.txt; $logFile ::: Can create your own file name. ^___^ Log::useDailyFiles(storage_path().'/logs/'.$logFile);
This only applies to new installations of Laravel 4.2. If you've upgraded an existing 4.1 application (and did not make changes to the way logs are created and stored), everything should still work.
##Screen Shot
##Installation
Add bankdev/logviewer
as a requirement to composer.json
:
{ ... "require": { ... "bankdev/logviewer": "dev-master" ... }, }
Update composer:
$ php composer.phar update
Add the provider to your app/config/app.php
:
'providers' => array( ... 'bankdev\Logviewer\LogviewerServiceProvider', ),
Publish package assets:
$ php artisan asset:publish bankdev/logviewer
(Optional) You can configure your composer.json
to do this after each $ composer update
:
"scripts":{
"post-update-cmd":[
"php artisan asset:publish bankdev/logviewer",
"php artisan optimize",
]
},
(Optional) Publish package config:
$ php artisan config:publish bankdev/logviewer
Please note: if you have made changes in your app/config/packages/bankdev/logviewer/config.php
, DO NOT publish the package config again. It will overwrite yours without any warning.
##Usage and Configuration
###Usage $fileName By default, LogViewer will register itself a couple of routes:
logviewer
-> Redirect to today's log, showing all levels.logviewer/$app/$sapi/$fileName/delete
-> Delete log from$sapi
(see: php_sapi_name).logviewer/$app/$sapi/$fileName/$level?
-> Show log from$sapi
on$fileName
with$level
(if not supplied, defaults to all).
LogViewer also registers a couple filters:
logviewer.logs
: aggregates all the logs in your configured monitored directories and shares them with the$logs
variable.logviewer.messages
: Checks if there are success, error, or info flash messages in the session and sets the$has_messages
variable as true or false.
###Configuration
base_url
: The URL LogViewer will be available on. You can have this nested (for example:admin/logviewer
). Default:logviewer
.filters
: Before and After filters to apply to the routes. We define no filters by default, as not everyone uses authentication or the same filter names.global
: Filters that affect the entirety of the logviewer. For example:'global' => array('before' => 'auth'),
will apply the default Laravelauth
filter to the logviewer, requiring a logged in user for all routes.view
: Filters that affect the viewing of log files.delete
: Filter that affect the deletion of log files.
log_dirs
: Associative array of log directories to monitor. Array keys are the 'names' of your applications, values are the paths to theirapp/storage/logs
dir (no trailing slash). Default:array('app' => storage_path().'/logs')
.log_order
: Order log contents ascending or descending. Default: 'asc'.per_page
: The number of log messages to show per page via Pagination. Default: 10.view
: The name (and location) of the view used to display logs. For more information, check out the 'Advanced Usage' section for detailed information about the variables passed to this view. Default: 'logviewer::viewer'.p_view
: The pagination view to use. When using Bootstrap 3 as the default for an application, the pagination would be broken within LogViewer. If you create your own view, be sure to change this if you use Bootstrap 3 (or write your own pagination view) Default: 'pagination::slider'.
Advanced Usage
Don't like the way LogViewer looks? Need to integrate it better with your application's theme? You can do so by creating your own view and changing the configuration option. Here are the variables that are sent to the view:
$has_messages
: Boolean. Thelogviewer.messages
filter determines if there are success, error, or info flash messages in the session. Used to hide the flash messages container.$logs
: Array. Aggregated logs, generated by thelogviewer.logs
filter, from all monitored applications. Grouped by SAPI and application. Structure:- SAPI as key, value is an array with keys:
sapi
: Human-readable SAPI.logs
: Application 'short name' as key, value is an array of log dates.
- SAPI as key, value is an array with keys:
$log
: Array. Currently selected log's contents. Each message is split into an array. Structure:level
: String. The level of the log message.header
: String. The first line of the log message.stack
: String. The rest of the log message. Possibly blank, if the message did not contain a stack trace.
$empty
: Boolean. Whether the current log is empty or not.$fileName
: String. The FileName of the currently selected log.$sapi
: String. The human-readable SAPI of the currently selected log.$sapi_plain
: String. The SAPI of the currently selected log. Used in the URI.$url
: String. The base URL from configuration.$levels
: Array. All possible log levels, perpsr/log
.$path
: String. The array key of the currently selected log's application.