mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-08 14:16:42 +02:00
CS fixes
This commit is contained in:
@@ -21,16 +21,16 @@ interface FormatterInterface
|
|||||||
/**
|
/**
|
||||||
* Formats a log record.
|
* Formats a log record.
|
||||||
*
|
*
|
||||||
* @param array $record A record to format
|
* @param array $record A record to format
|
||||||
* @return mixed The formatted record
|
* @return mixed The formatted record
|
||||||
*/
|
*/
|
||||||
function format(array $record);
|
public function format(array $record);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats a set of log records.
|
* Formats a set of log records.
|
||||||
*
|
*
|
||||||
* @param array $records A set of records to format
|
* @param array $records A set of records to format
|
||||||
* @return mixed The formatted set of records
|
* @return mixed The formatted set of records
|
||||||
*/
|
*/
|
||||||
function formatBatch(array $records);
|
public function formatBatch(array $records);
|
||||||
}
|
}
|
||||||
|
@@ -11,8 +11,6 @@
|
|||||||
|
|
||||||
namespace Monolog\Formatter;
|
namespace Monolog\Formatter;
|
||||||
|
|
||||||
use Monolog\Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes whatever record data is passed to it as json
|
* Encodes whatever record data is passed to it as json
|
||||||
*
|
*
|
||||||
|
@@ -11,8 +11,6 @@
|
|||||||
|
|
||||||
namespace Monolog\Formatter;
|
namespace Monolog\Formatter;
|
||||||
|
|
||||||
use Monolog\Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats incoming records into a one-line string
|
* Formats incoming records into a one-line string
|
||||||
*
|
*
|
||||||
@@ -28,7 +26,7 @@ class LineFormatter extends NormalizerFormatter
|
|||||||
protected $format;
|
protected $format;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $format The format of the message
|
* @param string $format The format of the message
|
||||||
* @param string $dateFormat The format of the timestamp: one supported by DateTime::format
|
* @param string $dateFormat The format of the timestamp: one supported by DateTime::format
|
||||||
*/
|
*/
|
||||||
public function __construct($format = null, $dateFormat = null)
|
public function __construct($format = null, $dateFormat = null)
|
||||||
|
@@ -11,8 +11,6 @@
|
|||||||
|
|
||||||
namespace Monolog\Formatter;
|
namespace Monolog\Formatter;
|
||||||
|
|
||||||
use Monolog\Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Normalizes incoming records to remove objects/resources so it's easier to dump to various targets
|
* Normalizes incoming records to remove objects/resources so it's easier to dump to various targets
|
||||||
*
|
*
|
||||||
|
@@ -32,7 +32,7 @@ abstract class AbstractHandler implements HandlerInterface
|
|||||||
protected $processors = array();
|
protected $processors = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param integer $level The minimum logging level at which this handler will be triggered
|
* @param integer $level The minimum logging level at which this handler will be triggered
|
||||||
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
||||||
*/
|
*/
|
||||||
public function __construct($level = Logger::DEBUG, $bubble = true)
|
public function __construct($level = Logger::DEBUG, $bubble = true)
|
||||||
@@ -87,6 +87,7 @@ abstract class AbstractHandler implements HandlerInterface
|
|||||||
if (!$this->processors) {
|
if (!$this->processors) {
|
||||||
throw new \LogicException('You tried to pop from an empty processor stack.');
|
throw new \LogicException('You tried to pop from an empty processor stack.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_shift($this->processors);
|
return array_shift($this->processors);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,7 +157,7 @@ abstract class AbstractHandler implements HandlerInterface
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->close();
|
$this->close();
|
||||||
} catch(\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,10 +11,6 @@
|
|||||||
|
|
||||||
namespace Monolog\Handler;
|
namespace Monolog\Handler;
|
||||||
|
|
||||||
use Monolog\Logger;
|
|
||||||
use Monolog\Formatter\FormatterInterface;
|
|
||||||
use Monolog\Formatter\LineFormatter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base Handler class providing the Handler structure
|
* Base Handler class providing the Handler structure
|
||||||
*
|
*
|
||||||
@@ -46,7 +42,7 @@ abstract class AbstractProcessingHandler extends AbstractHandler
|
|||||||
/**
|
/**
|
||||||
* Writes the record down to the log of the implementing handler
|
* Writes the record down to the log of the implementing handler
|
||||||
*
|
*
|
||||||
* @param array $record
|
* @param array $record
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
abstract protected function write(array $record);
|
abstract protected function write(array $record);
|
||||||
@@ -54,7 +50,7 @@ abstract class AbstractProcessingHandler extends AbstractHandler
|
|||||||
/**
|
/**
|
||||||
* Processes a record.
|
* Processes a record.
|
||||||
*
|
*
|
||||||
* @param array $record
|
* @param array $record
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function processRecord(array $record)
|
protected function processRecord(array $record)
|
||||||
|
@@ -28,10 +28,10 @@ class BufferHandler extends AbstractHandler
|
|||||||
protected $buffer = array();
|
protected $buffer = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param HandlerInterface $handler Handler.
|
* @param HandlerInterface $handler Handler.
|
||||||
* @param integer $bufferSize How many entries should be buffered at most, beyond that the oldest items are removed from the buffer.
|
* @param integer $bufferSize How many entries should be buffered at most, beyond that the oldest items are removed from the buffer.
|
||||||
* @param integer $level The minimum logging level at which this handler will be triggered
|
* @param integer $level The minimum logging level at which this handler will be triggered
|
||||||
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
||||||
*/
|
*/
|
||||||
public function __construct(HandlerInterface $handler, $bufferSize = 0, $level = Logger::DEBUG, $bubble = true)
|
public function __construct(HandlerInterface $handler, $bufferSize = 0, $level = Logger::DEBUG, $bubble = true)
|
||||||
{
|
{
|
||||||
@@ -65,7 +65,7 @@ class BufferHandler extends AbstractHandler
|
|||||||
*/
|
*/
|
||||||
public function close()
|
public function close()
|
||||||
{
|
{
|
||||||
if($this->buffer) {
|
if ($this->buffer) {
|
||||||
$this->handler->handleBatch($this->buffer);
|
$this->handler->handleBatch($this->buffer);
|
||||||
$this->buffer = array();
|
$this->buffer = array();
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
namespace Monolog\Handler;
|
namespace Monolog\Handler;
|
||||||
|
|
||||||
use Monolog\Logger;
|
|
||||||
use Monolog\Formatter\ChromePHPFormatter;
|
use Monolog\Formatter\ChromePHPFormatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,9 +30,9 @@ class ChromePHPHandler extends AbstractProcessingHandler
|
|||||||
*/
|
*/
|
||||||
const HEADER_NAME = 'X-ChromePhp-Data';
|
const HEADER_NAME = 'X-ChromePhp-Data';
|
||||||
|
|
||||||
static protected $initialized = false;
|
protected static $initialized = false;
|
||||||
|
|
||||||
static protected $json = array(
|
protected static $json = array(
|
||||||
'version' => self::VERSION,
|
'version' => self::VERSION,
|
||||||
'columns' => array('label', 'log', 'backtrace', 'type'),
|
'columns' => array('label', 'log', 'backtrace', 'type'),
|
||||||
'rows' => array(),
|
'rows' => array(),
|
||||||
|
@@ -21,8 +21,8 @@ interface ActivationStrategyInterface
|
|||||||
/**
|
/**
|
||||||
* Returns whether the given record activates the handler.
|
* Returns whether the given record activates the handler.
|
||||||
*
|
*
|
||||||
* @param array $record
|
* @param array $record
|
||||||
* @return Boolean
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
function isHandlerActivated(array $record);
|
public function isHandlerActivated(array $record);
|
||||||
}
|
}
|
@@ -34,11 +34,11 @@ class FingersCrossedHandler extends AbstractHandler
|
|||||||
protected $stopBuffering;
|
protected $stopBuffering;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param callback|HandlerInterface $handler Handler or factory callback($record, $fingersCrossedHandler).
|
* @param callback|HandlerInterface $handler Handler or factory callback($record, $fingersCrossedHandler).
|
||||||
* @param int|ActivationStrategyInterface $activationStrategy Strategy which determines when this handler takes action
|
* @param int|ActivationStrategyInterface $activationStrategy Strategy which determines when this handler takes action
|
||||||
* @param int $bufferSize How many entries should be buffered at most, beyond that the oldest items are removed from the buffer.
|
* @param int $bufferSize How many entries should be buffered at most, beyond that the oldest items are removed from the buffer.
|
||||||
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
||||||
* @param Boolean $stopBuffering Whether the handler should stop buffering after being triggered (default true)
|
* @param Boolean $stopBuffering Whether the handler should stop buffering after being triggered (default true)
|
||||||
*/
|
*/
|
||||||
public function __construct($handler, $activationStrategy = null, $bufferSize = 0, $bubble = true, $stopBuffering = true)
|
public function __construct($handler, $activationStrategy = null, $bufferSize = 0, $bubble = true, $stopBuffering = true)
|
||||||
{
|
{
|
||||||
|
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
namespace Monolog\Handler;
|
namespace Monolog\Handler;
|
||||||
|
|
||||||
use Monolog\Logger;
|
|
||||||
use Monolog\Formatter\WildfireFormatter;
|
use Monolog\Formatter\WildfireFormatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,9 +56,9 @@ class FirePHPHandler extends AbstractProcessingHandler
|
|||||||
/**
|
/**
|
||||||
* Base header creation function used by init headers & record headers
|
* Base header creation function used by init headers & record headers
|
||||||
*
|
*
|
||||||
* @param array $meta Wildfire Plugin, Protocol & Structure Indexes
|
* @param array $meta Wildfire Plugin, Protocol & Structure Indexes
|
||||||
* @param string $message Log message
|
* @param string $message Log message
|
||||||
* @return array Complete header string ready for the client as key and message as value
|
* @return array Complete header string ready for the client as key and message as value
|
||||||
*/
|
*/
|
||||||
protected function createHeader(array $meta, $message)
|
protected function createHeader(array $meta, $message)
|
||||||
{
|
{
|
||||||
@@ -72,7 +71,7 @@ class FirePHPHandler extends AbstractProcessingHandler
|
|||||||
* Creates message header from record
|
* Creates message header from record
|
||||||
*
|
*
|
||||||
* @see createHeader()
|
* @see createHeader()
|
||||||
* @param array $record
|
* @param array $record
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function createRecordHeader(array $record)
|
protected function createRecordHeader(array $record)
|
||||||
|
@@ -30,8 +30,8 @@ class GelfHandler extends AbstractProcessingHandler
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Gelf\IMessagePublisher $publisher a publisher object
|
* @param Gelf\IMessagePublisher $publisher a publisher object
|
||||||
* @param integer $level The minimum logging level at which this handler will be triggered
|
* @param integer $level The minimum logging level at which this handler will be triggered
|
||||||
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
||||||
*/
|
*/
|
||||||
public function __construct(IMessagePublisher $publisher, $level = Logger::DEBUG, $bubble = true)
|
public function __construct(IMessagePublisher $publisher, $level = Logger::DEBUG, $bubble = true)
|
||||||
{
|
{
|
||||||
|
@@ -21,8 +21,8 @@ class GroupHandler extends AbstractHandler
|
|||||||
protected $handlers;
|
protected $handlers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $handlers Array of Handlers.
|
* @param array $handlers Array of Handlers.
|
||||||
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
||||||
*/
|
*/
|
||||||
public function __construct(array $handlers, $bubble = true)
|
public function __construct(array $handlers, $bubble = true)
|
||||||
{
|
{
|
||||||
|
@@ -27,51 +27,51 @@ interface HandlerInterface
|
|||||||
*
|
*
|
||||||
* @return Boolean
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
function isHandling(array $record);
|
public function isHandling(array $record);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles a record.
|
* Handles a record.
|
||||||
*
|
*
|
||||||
* The return value of this function controls the bubbling process of the handler stack.
|
* The return value of this function controls the bubbling process of the handler stack.
|
||||||
*
|
*
|
||||||
* @param array $record The record to handle
|
* @param array $record The record to handle
|
||||||
* @return Boolean True means that this handler handled the record, and that bubbling is not permitted.
|
* @return Boolean True means that this handler handled the record, and that bubbling is not permitted.
|
||||||
* False means the record was either not processed or that this handler allows bubbling.
|
* False means the record was either not processed or that this handler allows bubbling.
|
||||||
*/
|
*/
|
||||||
function handle(array $record);
|
public function handle(array $record);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles a set of records at once.
|
* Handles a set of records at once.
|
||||||
*
|
*
|
||||||
* @param array $records The records to handle (an array of record arrays)
|
* @param array $records The records to handle (an array of record arrays)
|
||||||
*/
|
*/
|
||||||
function handleBatch(array $records);
|
public function handleBatch(array $records);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a processor in the stack.
|
* Adds a processor in the stack.
|
||||||
*
|
*
|
||||||
* @param callable $callback
|
* @param callable $callback
|
||||||
*/
|
*/
|
||||||
function pushProcessor($callback);
|
public function pushProcessor($callback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the processor on top of the stack and returns it.
|
* Removes the processor on top of the stack and returns it.
|
||||||
*
|
*
|
||||||
* @return callable
|
* @return callable
|
||||||
*/
|
*/
|
||||||
function popProcessor();
|
public function popProcessor();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the formatter.
|
* Sets the formatter.
|
||||||
*
|
*
|
||||||
* @param FormatterInterface $formatter
|
* @param FormatterInterface $formatter
|
||||||
*/
|
*/
|
||||||
function setFormatter(FormatterInterface $formatter);
|
public function setFormatter(FormatterInterface $formatter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the formatter.
|
* Gets the formatter.
|
||||||
*
|
*
|
||||||
* @return FormatterInterface
|
* @return FormatterInterface
|
||||||
*/
|
*/
|
||||||
function getFormatter();
|
public function getFormatter();
|
||||||
}
|
}
|
||||||
|
@@ -41,7 +41,7 @@ abstract class MailHandler extends AbstractProcessingHandler
|
|||||||
* Send a mail with the given content
|
* Send a mail with the given content
|
||||||
*
|
*
|
||||||
* @param string $content
|
* @param string $content
|
||||||
* @param array $records the array of log records that formed this content
|
* @param array $records the array of log records that formed this content
|
||||||
*/
|
*/
|
||||||
abstract protected function send($content, array $records);
|
abstract protected function send($content, array $records);
|
||||||
|
|
||||||
|
@@ -27,11 +27,11 @@ class NativeMailerHandler extends MailHandler
|
|||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string|array $to The receiver of the mail
|
* @param string|array $to The receiver of the mail
|
||||||
* @param string $subject The subject of the mail
|
* @param string $subject The subject of the mail
|
||||||
* @param string $from The sender of the mail
|
* @param string $from The sender of the mail
|
||||||
* @param integer $level The minimum logging level at which this handler will be triggered
|
* @param integer $level The minimum logging level at which this handler will be triggered
|
||||||
* @param boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
* @param boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
||||||
*/
|
*/
|
||||||
public function __construct($to, $subject, $from, $level = Logger::ERROR, $bubble = true)
|
public function __construct($to, $subject, $from, $level = Logger::ERROR, $bubble = true)
|
||||||
{
|
{
|
||||||
|
@@ -28,10 +28,10 @@ class RotatingFileHandler extends StreamHandler
|
|||||||
protected $mustRotate;
|
protected $mustRotate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $filename
|
* @param string $filename
|
||||||
* @param integer $maxFiles The maximal amount of files to keep (0 means unlimited)
|
* @param integer $maxFiles The maximal amount of files to keep (0 means unlimited)
|
||||||
* @param integer $level The minimum logging level at which this handler will be triggered
|
* @param integer $level The minimum logging level at which this handler will be triggered
|
||||||
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
||||||
*/
|
*/
|
||||||
public function __construct($filename, $maxFiles = 0, $level = Logger::DEBUG, $bubble = true)
|
public function __construct($filename, $maxFiles = 0, $level = Logger::DEBUG, $bubble = true)
|
||||||
{
|
{
|
||||||
|
@@ -26,8 +26,8 @@ class StreamHandler extends AbstractProcessingHandler
|
|||||||
protected $url;
|
protected $url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $stream
|
* @param string $stream
|
||||||
* @param integer $level The minimum logging level at which this handler will be triggered
|
* @param integer $level The minimum logging level at which this handler will be triggered
|
||||||
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
||||||
*/
|
*/
|
||||||
public function __construct($stream, $level = Logger::DEBUG, $bubble = true)
|
public function __construct($stream, $level = Logger::DEBUG, $bubble = true)
|
||||||
|
@@ -24,10 +24,10 @@ class SwiftMailerHandler extends MailHandler
|
|||||||
protected $message;
|
protected $message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Swift_Mailer $mailer The mailer to use
|
* @param \Swift_Mailer $mailer The mailer to use
|
||||||
* @param callback|\Swift_Message $message An example message for real messages, only the body will be replaced
|
* @param callback|\Swift_Message $message An example message for real messages, only the body will be replaced
|
||||||
* @param integer $level The minimum logging level at which this handler will be triggered
|
* @param integer $level The minimum logging level at which this handler will be triggered
|
||||||
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
||||||
*/
|
*/
|
||||||
public function __construct(\Swift_Mailer $mailer, $message, $level = Logger::ERROR, $bubble = true)
|
public function __construct(\Swift_Mailer $mailer, $message, $level = Logger::ERROR, $bubble = true)
|
||||||
{
|
{
|
||||||
|
@@ -58,10 +58,10 @@ class SyslogHandler extends AbstractProcessingHandler
|
|||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $ident
|
* @param string $ident
|
||||||
* @param mixed $facility
|
* @param mixed $facility
|
||||||
* @param integer $level The minimum logging level at which this handler will be triggered
|
* @param integer $level The minimum logging level at which this handler will be triggered
|
||||||
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
||||||
*/
|
*/
|
||||||
public function __construct($ident, $facility = LOG_USER, $level = Logger::DEBUG, $bubble = true)
|
public function __construct($ident, $facility = LOG_USER, $level = Logger::DEBUG, $bubble = true)
|
||||||
{
|
{
|
||||||
@@ -81,7 +81,7 @@ class SyslogHandler extends AbstractProcessingHandler
|
|||||||
// convert textual description of facility to syslog constant
|
// convert textual description of facility to syslog constant
|
||||||
if (array_key_exists(strtolower($facility), $this->facilities)) {
|
if (array_key_exists(strtolower($facility), $this->facilities)) {
|
||||||
$facility = $this->facilities[strtolower($facility)];
|
$facility = $this->facilities[strtolower($facility)];
|
||||||
} else if (!in_array($facility, array_values($this->facilities), true)) {
|
} elseif (!in_array($facility, array_values($this->facilities), true)) {
|
||||||
throw new \UnexpectedValueException('Unknown facility value "'.$facility.'" given');
|
throw new \UnexpectedValueException('Unknown facility value "'.$facility.'" given');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -120,6 +120,7 @@ class Logger
|
|||||||
if (!$this->handlers) {
|
if (!$this->handlers) {
|
||||||
throw new \LogicException('You tried to pop from an empty handler stack.');
|
throw new \LogicException('You tried to pop from an empty handler stack.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_shift($this->handlers);
|
return array_shift($this->handlers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,15 +147,16 @@ class Logger
|
|||||||
if (!$this->processors) {
|
if (!$this->processors) {
|
||||||
throw new \LogicException('You tried to pop from an empty processor stack.');
|
throw new \LogicException('You tried to pop from an empty processor stack.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_shift($this->processors);
|
return array_shift($this->processors);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a log record.
|
* Adds a log record.
|
||||||
*
|
*
|
||||||
* @param integer $level The logging level
|
* @param integer $level The logging level
|
||||||
* @param string $message The log message
|
* @param string $message The log message
|
||||||
* @param array $context The log context
|
* @param array $context The log context
|
||||||
* @return Boolean Whether the record has been processed
|
* @return Boolean Whether the record has been processed
|
||||||
*/
|
*/
|
||||||
public function addRecord($level, $message, array $context = array())
|
public function addRecord($level, $message, array $context = array())
|
||||||
@@ -198,8 +200,8 @@ class Logger
|
|||||||
/**
|
/**
|
||||||
* Adds a log record at the DEBUG level.
|
* Adds a log record at the DEBUG level.
|
||||||
*
|
*
|
||||||
* @param string $message The log message
|
* @param string $message The log message
|
||||||
* @param array $context The log context
|
* @param array $context The log context
|
||||||
* @return Boolean Whether the record has been processed
|
* @return Boolean Whether the record has been processed
|
||||||
*/
|
*/
|
||||||
public function addDebug($message, array $context = array())
|
public function addDebug($message, array $context = array())
|
||||||
@@ -210,8 +212,8 @@ class Logger
|
|||||||
/**
|
/**
|
||||||
* Adds a log record at the INFO level.
|
* Adds a log record at the INFO level.
|
||||||
*
|
*
|
||||||
* @param string $message The log message
|
* @param string $message The log message
|
||||||
* @param array $context The log context
|
* @param array $context The log context
|
||||||
* @return Boolean Whether the record has been processed
|
* @return Boolean Whether the record has been processed
|
||||||
*/
|
*/
|
||||||
public function addInfo($message, array $context = array())
|
public function addInfo($message, array $context = array())
|
||||||
@@ -222,8 +224,8 @@ class Logger
|
|||||||
/**
|
/**
|
||||||
* Adds a log record at the WARNING level.
|
* Adds a log record at the WARNING level.
|
||||||
*
|
*
|
||||||
* @param string $message The log message
|
* @param string $message The log message
|
||||||
* @param array $context The log context
|
* @param array $context The log context
|
||||||
* @return Boolean Whether the record has been processed
|
* @return Boolean Whether the record has been processed
|
||||||
*/
|
*/
|
||||||
public function addWarning($message, array $context = array())
|
public function addWarning($message, array $context = array())
|
||||||
@@ -234,8 +236,8 @@ class Logger
|
|||||||
/**
|
/**
|
||||||
* Adds a log record at the ERROR level.
|
* Adds a log record at the ERROR level.
|
||||||
*
|
*
|
||||||
* @param string $message The log message
|
* @param string $message The log message
|
||||||
* @param array $context The log context
|
* @param array $context The log context
|
||||||
* @return Boolean Whether the record has been processed
|
* @return Boolean Whether the record has been processed
|
||||||
*/
|
*/
|
||||||
public function addError($message, array $context = array())
|
public function addError($message, array $context = array())
|
||||||
@@ -246,8 +248,8 @@ class Logger
|
|||||||
/**
|
/**
|
||||||
* Adds a log record at the CRITICAL level.
|
* Adds a log record at the CRITICAL level.
|
||||||
*
|
*
|
||||||
* @param string $message The log message
|
* @param string $message The log message
|
||||||
* @param array $context The log context
|
* @param array $context The log context
|
||||||
* @return Boolean Whether the record has been processed
|
* @return Boolean Whether the record has been processed
|
||||||
*/
|
*/
|
||||||
public function addCritical($message, array $context = array())
|
public function addCritical($message, array $context = array())
|
||||||
@@ -258,8 +260,8 @@ class Logger
|
|||||||
/**
|
/**
|
||||||
* Adds a log record at the ALERT level.
|
* Adds a log record at the ALERT level.
|
||||||
*
|
*
|
||||||
* @param string $message The log message
|
* @param string $message The log message
|
||||||
* @param array $context The log context
|
* @param array $context The log context
|
||||||
* @return Boolean Whether the record has been processed
|
* @return Boolean Whether the record has been processed
|
||||||
*/
|
*/
|
||||||
public function addAlert($message, array $context = array())
|
public function addAlert($message, array $context = array())
|
||||||
@@ -270,7 +272,7 @@ class Logger
|
|||||||
/**
|
/**
|
||||||
* Gets the name of the logging level.
|
* Gets the name of the logging level.
|
||||||
*
|
*
|
||||||
* @param integer $level
|
* @param integer $level
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function getLevelName($level)
|
public static function getLevelName($level)
|
||||||
@@ -281,7 +283,7 @@ class Logger
|
|||||||
/**
|
/**
|
||||||
* Checks whether the Logger has a handler that listens on the given level
|
* Checks whether the Logger has a handler that listens on the given level
|
||||||
*
|
*
|
||||||
* @param integer $level
|
* @param integer $level
|
||||||
* @return Boolean
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
public function isHandling($level)
|
public function isHandling($level)
|
||||||
@@ -312,8 +314,8 @@ class Logger
|
|||||||
*
|
*
|
||||||
* This method allows to have an easy ZF compatibility.
|
* This method allows to have an easy ZF compatibility.
|
||||||
*
|
*
|
||||||
* @param string $message The log message
|
* @param string $message The log message
|
||||||
* @param array $context The log context
|
* @param array $context The log context
|
||||||
* @return Boolean Whether the record has been processed
|
* @return Boolean Whether the record has been processed
|
||||||
*/
|
*/
|
||||||
public function debug($message, array $context = array())
|
public function debug($message, array $context = array())
|
||||||
@@ -326,8 +328,8 @@ class Logger
|
|||||||
*
|
*
|
||||||
* This method allows to have an easy ZF compatibility.
|
* This method allows to have an easy ZF compatibility.
|
||||||
*
|
*
|
||||||
* @param string $message The log message
|
* @param string $message The log message
|
||||||
* @param array $context The log context
|
* @param array $context The log context
|
||||||
* @return Boolean Whether the record has been processed
|
* @return Boolean Whether the record has been processed
|
||||||
*/
|
*/
|
||||||
public function info($message, array $context = array())
|
public function info($message, array $context = array())
|
||||||
@@ -340,8 +342,8 @@ class Logger
|
|||||||
*
|
*
|
||||||
* This method allows to have an easy ZF compatibility.
|
* This method allows to have an easy ZF compatibility.
|
||||||
*
|
*
|
||||||
* @param string $message The log message
|
* @param string $message The log message
|
||||||
* @param array $context The log context
|
* @param array $context The log context
|
||||||
* @return Boolean Whether the record has been processed
|
* @return Boolean Whether the record has been processed
|
||||||
*/
|
*/
|
||||||
public function notice($message, array $context = array())
|
public function notice($message, array $context = array())
|
||||||
@@ -354,8 +356,8 @@ class Logger
|
|||||||
*
|
*
|
||||||
* This method allows to have an easy ZF compatibility.
|
* This method allows to have an easy ZF compatibility.
|
||||||
*
|
*
|
||||||
* @param string $message The log message
|
* @param string $message The log message
|
||||||
* @param array $context The log context
|
* @param array $context The log context
|
||||||
* @return Boolean Whether the record has been processed
|
* @return Boolean Whether the record has been processed
|
||||||
*/
|
*/
|
||||||
public function warn($message, array $context = array())
|
public function warn($message, array $context = array())
|
||||||
@@ -368,8 +370,8 @@ class Logger
|
|||||||
*
|
*
|
||||||
* This method allows to have an easy ZF compatibility.
|
* This method allows to have an easy ZF compatibility.
|
||||||
*
|
*
|
||||||
* @param string $message The log message
|
* @param string $message The log message
|
||||||
* @param array $context The log context
|
* @param array $context The log context
|
||||||
* @return Boolean Whether the record has been processed
|
* @return Boolean Whether the record has been processed
|
||||||
*/
|
*/
|
||||||
public function err($message, array $context = array())
|
public function err($message, array $context = array())
|
||||||
@@ -382,8 +384,8 @@ class Logger
|
|||||||
*
|
*
|
||||||
* This method allows to have an easy ZF compatibility.
|
* This method allows to have an easy ZF compatibility.
|
||||||
*
|
*
|
||||||
* @param string $message The log message
|
* @param string $message The log message
|
||||||
* @param array $context The log context
|
* @param array $context The log context
|
||||||
* @return Boolean Whether the record has been processed
|
* @return Boolean Whether the record has been processed
|
||||||
*/
|
*/
|
||||||
public function crit($message, array $context = array())
|
public function crit($message, array $context = array())
|
||||||
@@ -396,8 +398,8 @@ class Logger
|
|||||||
*
|
*
|
||||||
* This method allows to have an easy ZF compatibility.
|
* This method allows to have an easy ZF compatibility.
|
||||||
*
|
*
|
||||||
* @param string $message The log message
|
* @param string $message The log message
|
||||||
* @param array $context The log context
|
* @param array $context The log context
|
||||||
* @return Boolean Whether the record has been processed
|
* @return Boolean Whether the record has been processed
|
||||||
*/
|
*/
|
||||||
public function alert($message, array $context = array())
|
public function alert($message, array $context = array())
|
||||||
@@ -410,8 +412,8 @@ class Logger
|
|||||||
*
|
*
|
||||||
* This method allows to have an easy ZF compatibility.
|
* This method allows to have an easy ZF compatibility.
|
||||||
*
|
*
|
||||||
* @param string $message The log message
|
* @param string $message The log message
|
||||||
* @param array $context The log context
|
* @param array $context The log context
|
||||||
* @return Boolean Whether the record has been processed
|
* @return Boolean Whether the record has been processed
|
||||||
*/
|
*/
|
||||||
public function emerg($message, array $context = array())
|
public function emerg($message, array $context = array())
|
||||||
|
@@ -25,7 +25,7 @@ namespace Monolog\Processor;
|
|||||||
class IntrospectionProcessor
|
class IntrospectionProcessor
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array $record
|
* @param array $record
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function __invoke(array $record)
|
public function __invoke(array $record)
|
||||||
|
@@ -20,7 +20,7 @@ namespace Monolog\Processor;
|
|||||||
class MemoryPeakUsageProcessor extends MemoryProcessor
|
class MemoryPeakUsageProcessor extends MemoryProcessor
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array $record
|
* @param array $record
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function __invoke(array $record)
|
public function __invoke(array $record)
|
||||||
|
@@ -31,7 +31,7 @@ abstract class MemoryProcessor
|
|||||||
/**
|
/**
|
||||||
* Formats bytes into a human readable string
|
* Formats bytes into a human readable string
|
||||||
*
|
*
|
||||||
* @param int $bytes
|
* @param int $bytes
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected static function formatBytes($bytes)
|
protected static function formatBytes($bytes)
|
||||||
|
@@ -20,7 +20,7 @@ namespace Monolog\Processor;
|
|||||||
class MemoryUsageProcessor extends MemoryProcessor
|
class MemoryUsageProcessor extends MemoryProcessor
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array $record
|
* @param array $record
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function __invoke(array $record)
|
public function __invoke(array $record)
|
||||||
|
@@ -35,7 +35,7 @@ class WebProcessor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $record
|
* @param array $record
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function __invoke(array $record)
|
public function __invoke(array $record)
|
||||||
|
@@ -11,8 +11,6 @@
|
|||||||
|
|
||||||
namespace Monolog\Formatter;
|
namespace Monolog\Formatter;
|
||||||
|
|
||||||
use Monolog\Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers Monolog\Formatter\LineFormatter
|
* @covers Monolog\Formatter\LineFormatter
|
||||||
*/
|
*/
|
||||||
|
@@ -11,8 +11,6 @@
|
|||||||
|
|
||||||
namespace Monolog\Formatter;
|
namespace Monolog\Formatter;
|
||||||
|
|
||||||
use Monolog\Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers Monolog\Formatter\NormalizerFormatter
|
* @covers Monolog\Formatter\NormalizerFormatter
|
||||||
*/
|
*/
|
||||||
|
@@ -9,11 +9,11 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
spl_autoload_register(function($class)
|
spl_autoload_register(function($class) {
|
||||||
{
|
|
||||||
$file = __DIR__.'/../../../../src/'.strtr($class, '\\', '/').'.php';
|
$file = __DIR__.'/../../../../src/'.strtr($class, '\\', '/').'.php';
|
||||||
if (file_exists($file)) {
|
if (file_exists($file)) {
|
||||||
require $file;
|
require $file;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -38,6 +38,7 @@ class GelfHandlerTest extends TestCase
|
|||||||
protected function getHandler($messagePublisher)
|
protected function getHandler($messagePublisher)
|
||||||
{
|
{
|
||||||
$handler = new GelfHandler($messagePublisher);
|
$handler = new GelfHandler($messagePublisher);
|
||||||
|
|
||||||
return $handler;
|
return $handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,11 +16,11 @@ use Gelf\Message;
|
|||||||
|
|
||||||
class MockMessagePublisher extends MessagePublisher
|
class MockMessagePublisher extends MessagePublisher
|
||||||
{
|
{
|
||||||
public function publish(Message $message) {
|
public function publish(Message $message)
|
||||||
|
{
|
||||||
$this->lastMessage = $message;
|
$this->lastMessage = $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public $lastMessage = null;
|
public $lastMessage = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -48,7 +48,8 @@ class MongoDBHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!class_exists('Mongo')) {
|
if (!class_exists('Mongo')) {
|
||||||
class Mongo {
|
class Mongo
|
||||||
|
{
|
||||||
public function selectCollection() {}
|
public function selectCollection() {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -12,7 +12,6 @@
|
|||||||
namespace Monolog\Handler;
|
namespace Monolog\Handler;
|
||||||
|
|
||||||
use Monolog\TestCase;
|
use Monolog\TestCase;
|
||||||
use Monolog\Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers Monolog\Handler\RotatingFileHandler
|
* @covers Monolog\Handler\RotatingFileHandler
|
||||||
|
@@ -120,12 +120,12 @@ class SocketHandlerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->setMockHandler(array('fwrite'));
|
$this->setMockHandler(array('fwrite'));
|
||||||
|
|
||||||
$callback = function($arg)
|
$callback = function($arg) {
|
||||||
{
|
|
||||||
$map = array(
|
$map = array(
|
||||||
'Hello world' => 6,
|
'Hello world' => 6,
|
||||||
'world' => false,
|
'world' => false,
|
||||||
);
|
);
|
||||||
|
|
||||||
return $map[$arg];
|
return $map[$arg];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -143,12 +143,12 @@ class SocketHandlerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->setMockHandler(array('fwrite', 'streamGetMetadata'));
|
$this->setMockHandler(array('fwrite', 'streamGetMetadata'));
|
||||||
|
|
||||||
$callback = function($arg)
|
$callback = function($arg) {
|
||||||
{
|
|
||||||
$map = array(
|
$map = array(
|
||||||
'Hello world' => 6,
|
'Hello world' => 6,
|
||||||
'world' => 5,
|
'world' => 5,
|
||||||
);
|
);
|
||||||
|
|
||||||
return $map[$arg];
|
return $map[$arg];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -159,7 +159,6 @@ class SocketHandlerTest extends TestCase
|
|||||||
->method('streamGetMetadata')
|
->method('streamGetMetadata')
|
||||||
->will($this->returnValue(array('timed_out' => true)));
|
->will($this->returnValue(array('timed_out' => true)));
|
||||||
|
|
||||||
|
|
||||||
$this->writeRecord('Hello world');
|
$this->writeRecord('Hello world');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,9 +170,9 @@ class SocketHandlerTest extends TestCase
|
|||||||
$this->setMockHandler(array('fwrite', 'streamGetMetadata'));
|
$this->setMockHandler(array('fwrite', 'streamGetMetadata'));
|
||||||
|
|
||||||
$res = $this->res;
|
$res = $this->res;
|
||||||
$callback = function($string) use ($res)
|
$callback = function($string) use ($res) {
|
||||||
{
|
|
||||||
fclose($res);
|
fclose($res);
|
||||||
|
|
||||||
return strlen('Hello');
|
return strlen('Hello');
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -201,12 +200,12 @@ class SocketHandlerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->setMockHandler(array('fwrite'));
|
$this->setMockHandler(array('fwrite'));
|
||||||
|
|
||||||
$callback = function($arg)
|
$callback = function($arg) {
|
||||||
{
|
|
||||||
$map = array(
|
$map = array(
|
||||||
'Hello world' => 6,
|
'Hello world' => 6,
|
||||||
'world' => 5,
|
'world' => 5,
|
||||||
);
|
);
|
||||||
|
|
||||||
return $map[$arg];
|
return $map[$arg];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -11,8 +11,6 @@
|
|||||||
|
|
||||||
namespace Monolog\Handler;
|
namespace Monolog\Handler;
|
||||||
|
|
||||||
use Monolog\Logger;
|
|
||||||
|
|
||||||
class SyslogHandlerTest extends \PHPUnit_Framework_TestCase
|
class SyslogHandlerTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@@ -127,6 +127,7 @@ class LoggerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$logger->pushHandler($handler);
|
$logger->pushHandler($handler);
|
||||||
$logger->pushProcessor(function($record) {
|
$logger->pushProcessor(function($record) {
|
||||||
$record['extra']['win'] = true;
|
$record['extra']['win'] = true;
|
||||||
|
|
||||||
return $record;
|
return $record;
|
||||||
});
|
});
|
||||||
$logger->addError('test');
|
$logger->addError('test');
|
||||||
|
@@ -21,6 +21,7 @@ class IntrospectionProcessorTest extends TestCase
|
|||||||
$processor = new IntrospectionProcessor();
|
$processor = new IntrospectionProcessor();
|
||||||
$handler = new TestHandler();
|
$handler = new TestHandler();
|
||||||
$handler->pushProcessor($processor);
|
$handler->pushProcessor($processor);
|
||||||
|
|
||||||
return $handler;
|
return $handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,7 +32,7 @@ class IntrospectionProcessorTest extends TestCase
|
|||||||
$tester->test($handler, $this->getRecord());
|
$tester->test($handler, $this->getRecord());
|
||||||
list($record) = $handler->getRecords();
|
list($record) = $handler->getRecords();
|
||||||
$this->assertEquals(__FILE__, $record['extra']['file']);
|
$this->assertEquals(__FILE__, $record['extra']['file']);
|
||||||
$this->assertEquals(57, $record['extra']['line']);
|
$this->assertEquals(58, $record['extra']['line']);
|
||||||
$this->assertEquals('Acme\Tester', $record['extra']['class']);
|
$this->assertEquals('Acme\Tester', $record['extra']['class']);
|
||||||
$this->assertEquals('test', $record['extra']['function']);
|
$this->assertEquals('test', $record['extra']['function']);
|
||||||
}
|
}
|
||||||
@@ -42,7 +43,7 @@ class IntrospectionProcessorTest extends TestCase
|
|||||||
\Acme\tester($handler, $this->getRecord());
|
\Acme\tester($handler, $this->getRecord());
|
||||||
list($record) = $handler->getRecords();
|
list($record) = $handler->getRecords();
|
||||||
$this->assertEquals(__FILE__, $record['extra']['file']);
|
$this->assertEquals(__FILE__, $record['extra']['file']);
|
||||||
$this->assertEquals(63, $record['extra']['line']);
|
$this->assertEquals(64, $record['extra']['line']);
|
||||||
$this->assertEquals(null, $record['extra']['class']);
|
$this->assertEquals(null, $record['extra']['class']);
|
||||||
$this->assertEquals('Acme\tester', $record['extra']['function']);
|
$this->assertEquals('Acme\tester', $record['extra']['function']);
|
||||||
}
|
}
|
||||||
@@ -52,7 +53,7 @@ namespace Acme;
|
|||||||
|
|
||||||
class Tester
|
class Tester
|
||||||
{
|
{
|
||||||
function test($handler, $record)
|
public function test($handler, $record)
|
||||||
{
|
{
|
||||||
$handler->handle($record);
|
$handler->handle($record);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user