Skip to content
This repository has been archived by the owner on Mar 21, 2018. It is now read-only.

Commit

Permalink
Merge pull request #57 from GrahamCampbell/master
Browse files Browse the repository at this point in the history
Minor Tweaks
  • Loading branch information
mikemand committed Feb 2, 2014
2 parents 5ee6447 + 1ca9197 commit 280850f
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 64 deletions.
10 changes: 8 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
language: php

php:
php:
- 5.3
- 5.4
- 5.5
- hhvm

before_script:
- composer self-update
- composer install --prefer-source --no-interaction --dev
- composer install --no-interaction --prefer-source --dev

script:
- phpunit

matrix:
allow_failures:
- php: hhvm
fast_finish: true
18 changes: 9 additions & 9 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
MIT License
MIT License

Copyright (c) 2013 Micheal Mand

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ By default, LogViewer will register itself a couple of routes:
* `logviewer/$app/$sapi/$date/delete` -> Delete log from `$sapi` (see: [php\_sapi\_name](http://php.net/manual/en/function.php-sapi-name.php)) on `$date` (`Y-m-d` format).
* `logviewer/$app/$sapi/$date/$level?` -> Show log from `$sapi` on `$date` with `$level` (if not supplied, defaults to all).

LogViewer also registers a couple filters:
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.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"autoload": {
"classmap": [

],
"psr-0": {
"Kmd\\Logviewer": "src/"
Expand Down
11 changes: 5 additions & 6 deletions src/Kmd/Logviewer/Logviewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Lang;
use Psr\Log\LogLevel;
use ReflectionClass;

Expand All @@ -18,7 +17,7 @@ class Logviewer

/**
* Create a new Logviewer.
*
*
* @access public
* @param string
* @param string
Expand All @@ -36,7 +35,7 @@ public function __construct($app, $sapi, $date, $level = 'all')

/**
* Check if the log is empty.
*
*
* @access public
* @return boolean
*/
Expand All @@ -47,7 +46,7 @@ public function isEmpty()

/**
* Open and parse the log.
*
*
* @access public
* @return array
*/
Expand Down Expand Up @@ -100,7 +99,7 @@ public function log()

/**
* Delete the log.
*
*
* @access public
* @return boolean
*/
Expand All @@ -115,7 +114,7 @@ public function delete()

/**
* Get the log levels from psr/log.
*
*
* @access public
* @return array
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Kmd/Logviewer/LogviewerFacade.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace Kmd\Logviewer;

use Illuminate\Support\Facades\Facade;

class LogviewerFacade extends Facade
{
/**
Expand Down
8 changes: 4 additions & 4 deletions src/filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
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])) {
Expand All @@ -22,10 +22,10 @@
$files[$app] = array();
}
}

$logs[$sapi]['logs'] = $files;
}

View::share('logs', $logs);
});

Expand Down
4 changes: 2 additions & 2 deletions src/lang/de/logviewer.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

return array(

'delete' => array(
'modal' => array(
'header' => 'Bist du dir sicher?',
Expand Down Expand Up @@ -36,5 +36,5 @@
'cli' => 'CLI',
),
'title' => 'Laravel 4 LogViewer',

);
4 changes: 2 additions & 2 deletions src/lang/en/logviewer.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

return array(

'delete' => array(
'modal' => array(
'header' => 'Are you sure?',
Expand Down Expand Up @@ -36,5 +36,5 @@
'cli' => 'CLI',
),
'title' => 'Laravel 4 LogViewer',

);
4 changes: 2 additions & 2 deletions src/lang/es/logviewer.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

return array(

'delete' => array(
'modal' => array(
'header' => '¿Está seguro?',
Expand Down Expand Up @@ -36,5 +36,5 @@
'cli' => 'CLI',
),
'title' => 'Laravel 4 LogViewer',

);
4 changes: 2 additions & 2 deletions src/lang/nl/logviewer.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

return array(

'delete' => array(
'modal' => array(
'header' => 'Weet je het zeker?',
Expand Down Expand Up @@ -36,5 +36,5 @@
'cli' => 'CLI',
),
'title' => 'Laravel 4 LogViewer',

);
38 changes: 19 additions & 19 deletions src/views/viewer.blade.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
<!DOCTYPE html>
<html lang="{{ Config::get('app.locale') }}">

<head>
<meta charset="utf-8">
<title>{{ Lang::get('logviewer::logviewer.title') }}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">

{{ HTML::style('//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap.no-icons.min.css') }}
{{ HTML::style('//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-responsive.min.css') }}
{{ HTML::style('//netdna.bootstrapcdn.com/font-awesome/3.1.1/css/font-awesome.css') }}
{{ HTML::style('packages/kmd/logviewer/css/style.css') }}

<link rel="shortcut icon" href="{{ URL::to('packages/kmd/logviewer/ico/favicon.png') }}">
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="{{ URL::to('packages/kmd/logviewer/ico/apple-touch-icon-144-precomposed.png') }}">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="{{ URL::to('packages/kmd/logviewer/ico/apple-touch-icon-114-precomposed.png') }}">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="{{ URL::to('packages/kmd/logviewer/ico/apple-touch-icon-72-precomposed.png') }}">
<link rel="apple-touch-icon-precomposed" href="{{ URL::to('packages/kmd/logviewer/ico/apple-touch-icon-57-precomposed.png') }}">

<!--[if lt IE 9]>
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

{{ HTML::script('//cdnjs.cloudflare.com/ajax/libs/respond.js/1.3.0/respond.min.js') }}
</head>

<body>

<div class="wrapper">

<div class="container-fluid">

<header>
<div class="navbar navbar-static-top navbar-inverse">
<div class="navbar-inner">
Expand All @@ -50,9 +50,9 @@
</div>
</div>
</header>

<div class="row-fluid">

<div class="span2">
<div id="nav" class="well">
<ul class="nav nav-list">
Expand All @@ -76,7 +76,7 @@
</ul>
</div>
</div>

<div class="span10">
<div class="row-fluid{{ ! $has_messages ? ' hidden' : '' }}">
<div class="span12" id="messages">
Expand Down Expand Up @@ -133,13 +133,13 @@
</div>
</div>
</div>

</div>

</div>

</div>

<div id="delete_modal" class="modal hide fade">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
Expand All @@ -153,12 +153,12 @@
<button class="btn btn-danger" data-dismiss="modal">{{ Lang::get('logviewer::logviewer.delete.modal.btn.no') }}</button>
</div>
</div>

{{ HTML::script('//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js') }}
<script>window.jQuery || document.write('<script src="{{ URL::to("packages/kmd/logviewer/js/jquery-1.10.2.min.js") }}"><\/script>')</script>
{{ HTML::script('//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js') }}
{{ HTML::script('packages/kmd/logviewer/js/script.js') }}

</body>

</html>
24 changes: 12 additions & 12 deletions tests/LogviewerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
class LogviewerTest extends PHPUnit_Framework_TestCase
{
public $logviewer;

public function setUp()
{
parent::setUp();

$app = m::mock('AppMock');
$app->shouldReceive('instance')->once()->andReturn($app);

Expand All @@ -19,16 +19,16 @@ public function setUp()

$config->shouldReceive('get')->once()->with('logviewer::log_dirs')
->andReturn(array('app' => 'app/storage/logs'));

$this->logviewer = new Logviewer('app', 'cgi-fcgi', '2013-06-01');
}

public function tearDown()
{
$this->logviewer = null;
m::close();
}

public function testLogLevels()
{
$levels = array(
Expand All @@ -41,28 +41,28 @@ public function testLogLevels()
'INFO' => 'info',
'DEBUG' => 'debug',
);

$psr = $this->logviewer->getLevels();

$this->assertEquals(count($levels), count($psr));

$this->assertEquals($levels, $psr);
}

public function testLogAggregationRegex()
{
$date = '2013-06-01';

$pattern = '/.*(\d{4}-\d{2}-\d{2}).*/';

$files = array(
'/path/to/laravel/app/storage/logs/log-cli-2013-06-01.txt',
'/path/to/laravel/app/storage/logs/log-apache2handler-2013-06-01.txt',
'/path/to/laravel/app/storage/logs/log-apache2filter-2013-06-01.txt',
'/path/to/laravel/app/storage/logs/log-apache-2013-06-01.txt',
'/path/to/laravel/app/storage/logs/log-cgi-fcgi-2013-06-01.txt',
);

foreach ($files as &$file) {
$file = preg_replace($pattern, '$1', basename($file));
$this->assertEquals($file, $date);
Expand Down

0 comments on commit 280850f

Please sign in to comment.