library/rampage/core/Logger.php
public function log($priority, $message, $extra = array())
    {
        if (!is_int($priority) || ($priority<0) || ($priority>=count($this->priorities))) {
            throw new Exception\InvalidArgumentException(sprintf(
                '$priority must be an integer > 0 and < %d; received %s',
                count($this->priorities),
                var_export($priority, 1)
            ));
        }

        if (!is_array($extra) && !$extra instanceof Traversable) {
            throw new Exception\InvalidArgumentException(
                '$extra must be an array or implement Traversable'
            );
        } else if ($extra instanceof Traversable) {
            $extra = ArrayUtils::iteratorToArray($extra);
        }

        if ($this->writers->count() === 0) {
            throw new Exception\RuntimeException('No log writer specified');
        }

        $timestamp = new DateTime();

        if (is_array($message)) {
            $message = var_export($message, true);
        }

        foreach ($this->writers->toArray() as $writer) {
            $writer->write(array(
                'timestamp'    => $timestamp,
                'priority'     => (int) $priority,
                'priorityName' => $this->priorities[$priority],
                'message'      => $message,
                'extra'        => $extra
            ));
        }

        return $this;
    }
public function log($priority, $message, $extra = array())
    {
        if (!is_int($priority) || ($priority<0) || ($priority>=count($this->priorities))) {
            throw new Exception\InvalidArgumentException(sprintf(
                '$priority must be an integer > 0 and < %d; received %s',
                count($this->priorities),
                var_export($priority, 1)
            ));
        }

        if (!is_array($extra) && !$extra instanceof Traversable) {
            throw new Exception\InvalidArgumentException(
                '$extra must be an array or implement Traversable'
            );
        } else if ($extra instanceof Traversable) {
            $extra = ArrayUtils::iteratorToArray($extra);
        }

        if ($this->writers->count() === 0) {
            throw new Exception\RuntimeException('No log writer specified');
        }

        $timestamp = new DateTime();

        if (is_array($message)) {
            $message = var_export($message, true);
        }

        foreach ($this->writers->toArray() as $writer) {
            $writer->write(array(
                'timestamp'    => $timestamp,
                'priority'     => (int) $priority,
                'priorityName' => $this->priorities[$priority],
                'message'      => $message,
                'extra'        => $extra
            ));
        }

        return $this;
    }
public function log ( $ priority , $ message , $ extra = array ( ) ) { if ( ! is_int ( $ priority ) || ( $ priority < 0 ) || ( $ priority >= count ( $ this -> priorities ) ) ) { throw new Exception \ InvalidArgumentException ( sprintf ( '$priority must be an integer > 0 and < %d; received %s' , count ( $ this -> priorities ) , var_export ( $ priority , 1 ) ) ) ; } if ( ! is_array ( $ extra ) && ! $ extra instanceof Traversable ) { throw new Exception \ InvalidArgumentException ( '$extra must be an array or implement Traversable' ) ; } else if ( $ extra instanceof Traversable ) { $ extra = ArrayUtils :: iteratorToArray ( $ extra ) ; } if ( $ this -> writers -> count ( ) === 0 ) { throw new Exception \ RuntimeException ( 'No log writer specified' ) ; } $ timestamp = new DateTime ( ) ; if ( is_array ( $ message ) ) { $ message = var_export ( $ message , true ) ; } foreach ( $ this -> writers -> toArray ( ) as $ writer ) { $ writer -> write ( array ( 'timestamp' => $ timestamp , 'priority' => ( int ) $ priority , 'priorityName' => $ this -> priorities [ $ priority ] , 'message' => $ message , 'extra' => $ extra ) ) ; } return $ this ; }
Add a message as a log entry

In contrast of the zend implementation this does NOT cast the message to a
string, nor does it require a stringifyable object.

Leaving handling the message to the log writer makes much more sense then
the current, shitty implementation.

@param  int $priority
@param  mixed $message
@param  array|Traversable $extra
@return Logger
@throws Exception\InvalidArgumentException if message can't be cast to string
@throws Exception\InvalidArgumentException if extra can't be iterated over
@throws Exception\RuntimeException if no log writer specified
Add a message as a log entry