diff --git a/src/Kmd/Logviewer/Logviewer.php b/src/Kmd/Logviewer/Logviewer.php index 1f5e601..7280125 100644 --- a/src/Kmd/Logviewer/Logviewer.php +++ b/src/Kmd/Logviewer/Logviewer.php @@ -7,7 +7,7 @@ use ReflectionClass; class Logviewer -{ +{ public $path; public $sapi; public $date; @@ -58,7 +58,7 @@ public function log() $log_levels = $this->getLevels(); - $log_file = glob($this->path . '/log-' . $this->sapi . '*-' . $this->date . '.txt'); + $log_file = glob($this->path.'/log-'.$this->sapi.'*-'.$this->date.'.txt'); if (!empty($log_file)) { $this->empty = false; @@ -76,8 +76,8 @@ public function log() foreach ($headings as $h) { for ($i=0, $j = count($h); $i < $j; $i++) { foreach ($log_levels as $ll) { - if ($this->level == $ll OR $this->level == 'all') { - if (strpos(strtolower($h[$i]), strtolower('.' . $ll))) { + if ($this->level == $ll || $this->level == 'all') { + if (strpos(strtolower($h[$i]), strtolower('.'.$ll))) { $log[] = array('level' => $ll, 'header' => $h[$i], 'stack' => $log_data[$i]); } } @@ -89,7 +89,7 @@ public function log() unset($headings); unset($log_data); - if(strtolower(Config::get('logviewer::log_order')) == "desc"){ + if (strtolower(Config::get('logviewer::log_order')) == 'desc'){ $log = array_reverse($log); } @@ -104,7 +104,7 @@ public function log() */ public function delete() { - $log_file = glob($this->path . '/log-' . $this->sapi . '*-' . $this->date . '.txt'); + $log_file = glob($this->path.'/log-'.$this->sapi.'*-'.$this->date.'.txt'); if (!empty($log_file)) { return File::delete($log_file[0]); diff --git a/src/Kmd/Logviewer/LogviewerServiceProvider.php b/src/Kmd/Logviewer/LogviewerServiceProvider.php index ce66ea7..6b3fd59 100644 --- a/src/Kmd/Logviewer/LogviewerServiceProvider.php +++ b/src/Kmd/Logviewer/LogviewerServiceProvider.php @@ -22,9 +22,9 @@ public function boot() { $this->package('kmd/logviewer'); - include __DIR__ . '/../../routes.php'; - include __DIR__ . '/../../filters.php'; - include __DIR__ . '/../../macros.php'; + include __DIR__.'/../../routes.php'; + include __DIR__.'/../../filters.php'; + include __DIR__.'/../../macros.php'; } /** @@ -35,8 +35,7 @@ public function boot() */ public function register() { - $this->app['logviewer'] = $this->app->share(function ($app) - { + $this->app['logviewer'] = $this->app->share(function ($app) { return new Logviewer; }); } diff --git a/src/filters.php b/src/filters.php index d705060..cc08b95 100644 --- a/src/filters.php +++ b/src/filters.php @@ -3,29 +3,23 @@ Route::filter('logviewer.logs', function () { $logs = array(); - if( ! Lang::has('logviewer::logviewer.sapi')){ + if (!Lang::has('logviewer::logviewer.sapi')) { App::setLocale('en'); } - foreach (Lang::get('logviewer::logviewer.sapi') as $sapi => $human) - { + foreach (Lang::get('logviewer::logviewer.sapi') as $sapi => $human) { $logs[$sapi]['sapi'] = $human; $dirs = Config::get('logviewer::log_dirs'); $files = array(); - foreach ($dirs as $app => $dir) - { - $files[$app] = glob($dir . '/log-' . $sapi . '*', GLOB_BRACE); - if (is_array($files[$app])) - { + foreach ($dirs as $app => $dir) { + $files[$app] = glob($dir.'/log-'.$sapi.'*', GLOB_BRACE); + if (is_array($files[$app])) { $files[$app] = array_reverse($files[$app]); - foreach ($files[$app] as &$file) - { + foreach ($files[$app] as &$file) { $file = preg_replace('/.*(\d{4}-\d{2}-\d{2}).*/', '$1', basename($file)); } - } - else - { + } else { $files[$app] = array(); } } @@ -36,14 +30,10 @@ View::share('logs', $logs); }); -Route::filter('logviewer.messages', function () -{ - if (Session::has('success') OR Session::has('error') OR Session::has('info')) - { +Route::filter('logviewer.messages', function () { + if (Session::has('success') OR Session::has('error') OR Session::has('info')) { View::share('has_messages', true); - } - else - { + } else { View::share('has_messages', false); } }); diff --git a/src/macros.php b/src/macros.php index a374a63..d6cad76 100644 --- a/src/macros.php +++ b/src/macros.php @@ -5,13 +5,13 @@ $href = HTML::link($url, $text, $a_attr); $response = ''; - if( Request::is($url) || Request::is($url . '/*')) { + if (Request::is($url) || Request::is($url.'/*')) { if (isset($li_attrs['class'])) { - $li_attrs['class'] .= ' ' . $active_class; + $li_attrs['class'] .= ' '.$active_class; } else { $li_attrs['class'] = $active_class; } } - return '
  • ' . $href . '
  • '; + return '
  • '.$href.'
  • '; }); diff --git a/src/routes.php b/src/routes.php index bcde0a0..c32927f 100644 --- a/src/routes.php +++ b/src/routes.php @@ -43,7 +43,7 @@ Session::reflash(); } - return Redirect::to(Config::get('logviewer::base_url') . '/' . $path . '/' . $sapi . '/' . $today . '/all'); + return Redirect::to(Config::get('logviewer::base_url').'/'.$path.'/'.$sapi.'/'.$today.'/all'); }); $filters = Config::get('logviewer::filters.delete'); @@ -70,10 +70,10 @@ if ($logviewer->delete()) { $today = Carbon::today()->format('Y-m-d'); - return Redirect::to(Config::get('logviewer::base_url') . '/' . $path . '/' . $sapi . '/' . $today .'/all') + return Redirect::to(Config::get('logviewer::base_url').'/'.$path.'/'.$sapi.'/'.$today.'/all') ->with('success', Lang::get('logviewer::logviewer.delete.success')); } else { - return Redirect::to(Config::get('logviewer::base_url') . '/' . $path . '/' . $sapi . '/' . $date . '/all') + return Redirect::to(Config::get('logviewer::base_url').'/'.$path.'/'.$sapi.'/'.$date.'/all') ->with('error', Lang::get('logviewer::logviewer.delete.error')); } }); @@ -134,7 +134,7 @@ ->with('log', (count($log) > $page->getPerPage() ? array_slice($log, $page->getFrom()-1, $page->getPerPage()) : $log)) ->with('empty', $logviewer->isEmpty()) ->with('date', $date) - ->with('sapi', Lang::get('logviewer::logviewer.sapi.' . $sapi)) + ->with('sapi', Lang::get('logviewer::logviewer.sapi.'.$sapi)) ->with('sapi_plain', $sapi) ->with('url', Config::get('logviewer::base_url')) ->with('levels', $levels) diff --git a/src/views/viewer.blade.php b/src/views/viewer.blade.php index 20670ec..0b1d3fc 100644 --- a/src/views/viewer.blade.php +++ b/src/views/viewer.blade.php @@ -36,9 +36,9 @@
    {{ HTML::link($url, Lang::get('logviewer::logviewer.title'), array('class' => 'brand')) }} @if ( ! $empty) @@ -62,10 +62,10 @@ @foreach ($files['logs'] as $app => $file) @if ( ! empty($file)) - + @endif @@ -149,7 +149,7 @@

    {{ Lang::get('logviewer::logviewer.delete.modal.body') }}