Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'svn/log' of https://github.com/Intiilapa/zf2 into featu…
Browse files Browse the repository at this point in the history
…re/zend_log-svn_sync

Conflicts:
	documentation/manual/en/module_specs/Zend_Log-Formatters.xml
	documentation/manual/en/module_specs/Zend_Log-Writers.xml
	library/Zend/Log/Filter.php
	library/Zend/Log/Filter/AbstractFilter.php
	library/Zend/Log/Formatter.php
	library/Zend/Log/Writer.php
	tests/Zend/Log/Writer/FirebugTest.php
  • Loading branch information
weierophinney committed Mar 17, 2011
11 parents 99e328f + b4fd322 + b8ab939 + 66f51dc + 3894dbf + 07d1ba6 + bbae534 + 122c95e + 163c973 + 369dd16 + a75e0ac commit b1b6338
Show file tree
Hide file tree
Showing 35 changed files with 904 additions and 163 deletions.
7 changes: 0 additions & 7 deletions src/Exception/NotImplementedException.php

This file was deleted.

4 changes: 2 additions & 2 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ interface Factory
{
/**
* Construct a Zend_Log driver
*
*
* @param array|\Zend\Config\Config $config
* @return \Zend\Log\Factory
*/
static public function factory($config = array());
}
}
2 changes: 0 additions & 2 deletions src/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*
* @category Zend
* @package Zend_Log
* @subpackage Filter
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
Expand All @@ -27,7 +26,6 @@
/**
* @category Zend
* @package Zend_Log
* @subpackage Filter
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
Expand Down
10 changes: 5 additions & 5 deletions src/Filter/AbstractFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* @category Zend
* @package Zend_Log
* @subpackage Writer
* @subpackage Filter
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
Expand All @@ -28,19 +28,19 @@

/**
* @uses \Zend\Log\Exception\InvalidArgumentException
* @uses \Zend\Log\Filter\FilterInterface
* @uses \Zend\Log\FactoryInterface
* @uses \Zend\Log\Filter
* @uses \Zend\Log\Factory
* @category Zend
* @package Zend_Log
* @subpackage Writer
* @subpackage Filter
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class AbstractFilter implements Filter, Factory
{
/**
* Validate and optionally convert the config to array
*
*
* @param array|\Zend\Config\Config $config \Zend\Config\Config or Array
* @return array
* @throws \Zend\Log\Exception\InvalidArgumentException
Expand Down
5 changes: 3 additions & 2 deletions src/Filter/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class Message extends AbstractFilter
* Filter out any log messages not matching $regexp.
*
* @param string $regexp Regular expression to test the log message
* @return void
* @throws \Zend\Log\Exception\InvalidArgumentException
*/
public function __construct($regexp)
Expand All @@ -56,11 +57,11 @@ public function __construct($regexp)

/**
* Create a new instance of Zend_Log_Filter_Message
*
*
* @param array|\Zend\Config\Config $config
* @return \Zend\Log\Filter\Message
*/
static public function factory($config = array())
static public function factory($config = array())
{
$config = self::_parseConfig($config);
$config = array_merge(array(
Expand Down
13 changes: 7 additions & 6 deletions src/Filter/Priority.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ class Priority extends AbstractFilter
*
* @param integer $priority Priority
* @param string $operator Comparison operator
* @return void
* @throws \Zend\Log\Exception\InvalidArgumentException
*/
public function __construct($priority, $operator = null)
{
if (! is_integer($priority)) {
if (! is_int($priority)) {
throw new \Zend\Log\Exception\InvalidArgumentException('Priority must be an integer');
}

Expand All @@ -65,16 +66,16 @@ public function __construct($priority, $operator = null)

/**
* Create a new instance of Zend_Log_Filter_Priority
*
*
* @param array|\Zend\Config\Config $config
* @return \Zend\Log\Filter\Priority
* @throws \Zend\Log\Exception\InvalidArgumentException
*/
static public function factory($config = array())
static public function factory($config = array())
{
$config = self::_parseConfig($config);
$config = array_merge(array(
'priority' => null,
'priority' => null,
'operator' => null,
), $config);

Expand All @@ -86,9 +87,9 @@ static public function factory($config = array())
if (!is_numeric($config['priority'])) {
throw new \Zend\Log\Exception\InvalidArgumentException('Priority must be an integer.');
}

return new self(
(int) $config['priority'],
(int) $config['priority'],
$config['operator']
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Filter/SuppressFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ public function accept($event)

/**
* Create a new instance of Zend_Log_Filter_Suppress
*
*
* @param array|\Zend\Config\Config $config
* @return \Zend\Log\Filter\Suppress
* @return \Zend\Log\Filter\SuppressFilter
*/
static public function factory($config = array())
{
Expand Down
2 changes: 0 additions & 2 deletions src/Formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*
* @category Zend
* @package Zend_Log
* @subpackage Formatter
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
Expand All @@ -27,7 +26,6 @@
/**
* @category Zend
* @package Zend_Log
* @subpackage Formatter
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
Expand Down
40 changes: 40 additions & 0 deletions src/Formatter/AbstractFormatter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Log
* @subpackage Formatter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Log\Formatter;
use \Zend\Log\Factory,
\Zend\Log\Formatter;

/**
* @uses \Zend\Log\Factory
* @uses \Zend\Log\Formatter
* @category Zend
* @package Zend_Log
* @subpackage Formatter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class AbstractFormatter implements Formatter, Factory
{
}
17 changes: 14 additions & 3 deletions src/Formatter/Firebug.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,26 @@
use \Zend\Log\Formatter;

/**
* @uses \Zend\Log\Formatter\FormatterInterface
* @uses \Zend\Log\Formatter\AbstractFormatter
* @category Zend
* @package Zend_Log
* @subpackage Formatter
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Firebug implements Formatter
class Firebug extends AbstractFormatter
{
/**
* Factory for Zend_Log_Formatter_Firebug classe
*
* @param array|\Zend\Config\Config $options useless
* @return \Zend\Log\Formatter\Firebug
*/
public static function factory($options = array())
{
return new self;
}

/**
* This method formats the event for the firebug writer.
*
Expand All @@ -50,4 +61,4 @@ public function format($event)
{
return $event['message'];
}
}
}
38 changes: 31 additions & 7 deletions src/Formatter/Simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@

/**
* @uses \Zend\Log\Exception\InvalidArgumentException
* @uses \Zend\Log\Formatter\FormatterInterface
* @uses \Zend\Log\Formatter\AbstractFormatter
* @category Zend
* @package Zend_Log
* @subpackage Formatter
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Simple implements Formatter
class Simple extends AbstractFormatter
{
/**
* @var string
Expand All @@ -47,6 +47,7 @@ class Simple implements Formatter
* Class constructor
*
* @param null|string $format Format specifier for log messages
* @return void
* @throws \Zend\Log\Exception\InvalidArgumentException
*/
public function __construct($format = null)
Expand All @@ -55,13 +56,35 @@ public function __construct($format = null)
$format = self::DEFAULT_FORMAT . PHP_EOL;
}

if (! is_string($format)) {
if (!is_string($format)) {
throw new \Zend\Log\Exception\InvalidArgumentException('Format must be a string');
}

$this->_format = $format;
}

/**
* Factory for Zend_Log_Formatter_Simple classe
*
* @param array|\Zend\Config\Config $options
* @return \Zend\Log\Formatter\Simple
*/
public static function factory($options = array())
{
$format = null;
if (null !== $options) {
if ($options instanceof Zend\Config\Config) {
$options = $options->toArray();
}

if (array_key_exists('format', $options)) {
$format = $options['format'];
}
}

return new self($format);
}

/**
* Formats data into a single line to be written by the writer.
*
Expand All @@ -71,16 +94,17 @@ public function __construct($format = null)
public function format($event)
{
$output = $this->_format;
foreach ($event as $name => $value) {

foreach ($event as $name => $value) {
if ((is_object($value) && !method_exists($value,'__toString'))
|| is_array($value)) {

|| is_array($value)
) {
$value = gettype($value);
}

$output = str_replace("%$name%", $value, $output);
}

return $output;
}
}
}
Loading

0 comments on commit b1b6338

Please sign in to comment.