1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-01-16 21:08:34 +01:00

MessagesCollector is now compatible with PSR Log

added psr as requirement
This commit is contained in:
maximebf 2013-06-18 13:24:07 +09:00
parent 0a720e513c
commit 214c62bd85
5 changed files with 27 additions and 15 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
composer.lock
vendor

View File

@ -11,7 +11,8 @@
"homepage": "http://maximebf.com"
}],
"require": {
"php": ">=5.3.0"
"php": ">=5.3.0",
"psr/log": "~1.0"
},
"require-dev": {
"php": ">=5.3.0"

View File

@ -33,6 +33,9 @@ class MonologCollector extends AbstractProcessingHandler implements DataCollecto
);
}
/**
* {@inheritDoc}
*/
public function collect()
{
return array(
@ -41,11 +44,17 @@ class MonologCollector extends AbstractProcessingHandler implements DataCollecto
);
}
/**
* {@inheritDoc}
*/
public function getName()
{
return 'monolog';
}
/**
* {@inheritDoc}
*/
public function getWidgets()
{
return array(

View File

@ -10,13 +10,23 @@
namespace DebugBar\DataCollector;
use Psr\Log\AbstractLogger;
/**
* Provides a way to log messages
*/
class MessagesCollector extends DataCollector implements Renderable
class MessagesCollector extends AbstractLogger implements DataCollectorInterface, Renderable
{
protected $messages = array();
/**
* {@inheritDoc}
*/
public function log($level, $message, array $context = array())
{
$this->addMessage($message, $level);
}
/**
* Adds a message
*
@ -28,7 +38,7 @@ class MessagesCollector extends DataCollector implements Renderable
public function addMessage($message, $label = 'info')
{
$this->messages[] = array(
'message' => $this->formatVar($message),
'message' => print_r($message, true),
'is_string' => is_string($message),
'label' => $label,
'time' => microtime(true),

View File

@ -1,14 +1,4 @@
<?php
set_include_path(implode(PATH_SEPARATOR, array(
__DIR__,
__DIR__ . '/../src',
get_include_path()
)));
spl_autoload_register(function($className) {
if (substr($className, 0, 8) === 'DebugBar') {
$filename = str_replace('\\', DIRECTORY_SEPARATOR, trim($className, '\\')) . '.php';
require_once $filename;
}
});
$loader = require(dirname(__DIR__) . '/vendor/autoload.php');
$loader->add('DebugBar\Tests', __DIR__);