-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
99 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.travis.yml export-ignore | ||
/.scrutinizer.yml export-ignore | ||
/CHANGELOG.md export-ignore | ||
/CONTRIBUTING.md export-ignore | ||
/README.md export-ignore | ||
/phpunit.xml.dist export-ignore | ||
/tests export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# APIx-log changelog | ||
|
||
#### Version 1.0.1 (9-Jun-2015) | ||
- Added Scrutinizer checks. | ||
- Added `.gitattributes` file. | ||
- Added a unit tests `bootstrap.php` file. | ||
- Added a default timezone to the unit tests bootstraper. | ||
- Fixed the context array handler (convert data to JSON). | ||
- Added additional tests and minor changes. | ||
- Updated the examples in `README.md`. | ||
- Added a `CHANGELOG.md` file. | ||
|
||
#### Version 1.0.0 (30-Sept-2014) | ||
- Initial release. | ||
|
||
|
||
<pre> | ||
_|_| _|_| _| _| _| | ||
_| _| _| _| _| _| | ||
_| _| _| _| _| _|_| | ||
_|_|_|_| _|_|_| _| _|_| _|_| | ||
_| _| _| _| _| _| | ||
_| _| _| _| _| _| | ||
</pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ Basic usage (*standalone*) | |
```php | ||
use Apix\Log; | ||
|
||
$logger = new Logger\File('/tmp/alerts.log'); | ||
$logger = new Logger\File('/var/log/apix.log'); | ||
$logger->setMinLevel('alert'); // same as Psr\Log\LogLevel::ALERT | ||
|
||
// then later, just push/send an alert... | ||
|
@@ -31,16 +31,26 @@ Advanced usage (*multi-logs dispatcher*) | |
|
||
$logger = new Logger(); | ||
|
||
$file_log = new Logger\File('/tmp/debug.log'); | ||
$file_log->setMinLevel('debug'); // same as Psr\Log\LogLevel::DEBUG | ||
|
||
$mail_log = new Logger\Mail('[email protected]'); | ||
$mail_log->setMinLevel('critical'); // or Psr\Log\LogLevel::CRITICAL | ||
// The log bucket for critical, alert and emergency. | ||
$urgent_log = new Logger\Mail('[email protected]'); | ||
$urgent_log->setMinLevel('critical'); // same Psr\Log\LogLevel::CRITICAL | ||
|
||
// The log bucket for notice, warning and error. | ||
$prod_log = new Log\Logger\File('/var/log/apix_prod.log'); | ||
$prod_log->setMinLevel('notice'); // same Psr\Log\LogLevel::NOTICE | ||
|
||
$this->logger->add($mail_log); | ||
$this->logger->add($file_log); | ||
$this->logger->add($urgent_log); | ||
$this->logger->add($prod_log); | ||
|
||
if (DEBUG) { | ||
// The develop log bucket for info and debug | ||
$dev_log = new Log\Logger\File('/tmp/apix_develop.log'); | ||
$dev_log->setMinLevel('debug'); // same as Psr\Log\LogLevel::DEBUG | ||
|
||
$logger->add($dev_log); | ||
} | ||
|
||
// then notify the loggers... | ||
// then (later) notify the loggers... | ||
$this->logger->notice('Some notice...'); | ||
$this->logger->critical('Blahh blahh...'); | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,28 +121,7 @@ public function testLogWillNotProcess() | |
$this->logger->warning('test'); | ||
} | ||
|
||
// todo | ||
public function _testExample() | ||
{ | ||
$g = $this->_getMocklogger( array('process') ); | ||
$g->expects($this->once())->method('process'); | ||
|
||
$a = $this->_getMocklogger( array('process') ); | ||
$a->setMinLevel( LogLevel::ALERT ); | ||
$a->expects($this->once())->method('process'); | ||
|
||
$this->logger->add($g); | ||
$this->logger->add($a); | ||
|
||
$this->logger->alert('test'); | ||
$this->logger->debug('test'); | ||
|
||
} | ||
|
||
/** | ||
* @group test | ||
*/ | ||
public function testFunctional() | ||
public function TODO_testFunctional() | ||
{ | ||
// $this->expectOutputString('foo'); | ||
|
||
|
@@ -162,64 +141,34 @@ public function testFunctional() | |
|
||
$this->logger->debug('test filed logged'); | ||
$this->logger->alert('test by email {bb}', array('bb'=>123)); | ||
|
||
} | ||
|
||
public function _testHandlersNotCalledBeforeFirstHandling() | ||
/** | ||
* @group todo | ||
*/ | ||
public function testFunctionalExample() | ||
{ | ||
$l1 = $this->_getMocklogger(); | ||
$l1->expects($this->never()) | ||
->method('isHandling') | ||
->will($this->returnValue(false)); | ||
|
||
$l1->expects($this->once()) | ||
->method('process') | ||
->will($this->returnValue(false)); | ||
$logger = new Logger(); | ||
|
||
$this->logger->add($l1); | ||
|
||
$l2 = $this->_getMocklogger(); | ||
$l2->expects($this->once()) | ||
->method('isHandling') | ||
->will($this->returnValue(true)); | ||
// the log bucket for critical, alert and emergency | ||
$mail_log = new Logger\Mail('[email protected]'); | ||
$mail_log->setMinLevel('critical'); | ||
$this->logger->add($mail_log); | ||
|
||
$l2->expects($this->once()) | ||
->method('process') | ||
->will($this->returnValue(false)); | ||
// the log bucket for notice, warning and error | ||
$prod_log = new Logger\File('/tmp/apix_prod.log'); | ||
$prod_log->setMinLevel('notice'); | ||
$this->logger->add($prod_log); | ||
|
||
$this->logger->add($l2); | ||
if (true) { | ||
// the log bucket for info and debug | ||
$dev_log = new Logger\File('/tmp/apix_dev.log'); | ||
$this->logger->add($dev_log); | ||
} | ||
|
||
$l3 = $this->_getMocklogger(); | ||
$l3->expects($this->once()) | ||
->method('isHandling') | ||
->will($this->returnValue(false)) | ||
; | ||
$l3->expects($this->never()) | ||
->method('process') | ||
; | ||
$this->logger->add($l3); | ||
|
||
$this->logger->debug('test'); | ||
} | ||
|
||
public function _testGetFirstLoggerIndex() | ||
{ | ||
$l1 = $this->_getMocklogger(); | ||
$l1->expects($this->any()) | ||
->method('isHandling') | ||
->will($this->returnValue(false)); | ||
$this->logger->add($l1); | ||
|
||
$this->assertFalse($this->logger->getFirstLoggerIndex(LogLevel::DEBUG)); | ||
|
||
$l2 = $this->_getMocklogger(); | ||
$l2->setMinLevel( LogLevel::ALERT ); | ||
$l2->expects($this->any()) | ||
->method('isHandling') | ||
->will($this->returnValue(true)); | ||
$this->logger->add($l2); | ||
$this->logger->debug('test filed logged'); | ||
$this->logger->alert('test by email {bb}', array('bb'=>123)); | ||
|
||
$this->assertSame(0, $this->logger->getFirstLoggerIndex(LogLevel::DEBUG)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
/** | ||
* | ||
* This file is part of the Apix Project. | ||
* | ||
* (c) Franck Cassedanne <franck at ouarz.net> | ||
* | ||
* @license http://opensource.org/licenses/BSD-3-Clause New BSD License | ||
* | ||
*/ | ||
|
||
namespace Apix; | ||
|
||
// Set the default timezone | ||
date_default_timezone_set('UTC'); | ||
|
||
define('APP_VENDOR', realpath(__DIR__ . '/../vendor')); | ||
|
||
// Composer | ||
$loader = require APP_VENDOR . '/autoload.php'; |