diff --git a/composer.json b/composer.json index 30bbadc..6e5699e 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,14 @@ "require": { "php": ">=5.3.0" }, + "require-dev": { + "php": ">=5.3.0" + }, "autoload": { "psr-0": {"DebugBar": "src/"} + }, + "suggest": { + "kriswallsmith/assetic": "The best way to manage assets", + "monolog/monolog": "Log using Monolog" } } diff --git a/src/DebugBar/Bridge/MonologCollector.php b/src/DebugBar/Bridge/MonologCollector.php new file mode 100644 index 0000000..28e0ac3 --- /dev/null +++ b/src/DebugBar/Bridge/MonologCollector.php @@ -0,0 +1,56 @@ + + * $debugbar->addCollector(new MonologCollector($logger)); + * + */ +class MonologCollector extends AbstractProcessingHandler implements DataCollectorInterface, Renderable +{ + protected $records = array(); + + public function __construct(Logger $logger, $level = Logger::DEBUG, $bubble = true) + { + $logger->pushHandler($this); + } + + protected function write(array $record) + { + $this->records[] = array( + 'message' => $record['formatted'], + 'is_string' => true, + 'label' => strtolower($record['level_name']), + 'time' => $record['datetime']->format('U') + ); + } + + public function collect() + { + return $this->records; + } + + public function getName() + { + return 'monolog'; + } + + public function getWidgets() + { + return array( + "logs" => array( + "widget" => "PhpDebugBar.Widgets.MessagesWidget", + "map" => "monolog", + "default" => "[]" + ) + ); + } +}