lithium\analysis\logger\adapter\Growl::write PHP Method

write() public method

Writes $message to a new Growl notification.
public write ( string $priority, string $message, array $options = [] ) : Closure
$priority string The `Logger`-based priority of the message. This value is mapped to a Growl-specific priority value if possible.
$message string Message to be shown.
$options array Any options that are passed to the `notify()` method. See the `$options` parameter of `notify()`.
return Closure Function returning boolean `true` on successful write, `false` otherwise.
    public function write($priority, $message, array $options = array())
    {
        $_self =& $this;
        $_priorities = $this->_priorities;
        return function ($self, $params) use(&$_self, $_priorities) {
            $priority = 0;
            $options = $params['options'];
            if (isset($options['priority']) && isset($_priorities[$options['priority']])) {
                $priority = $_priorities[$options['priority']];
            }
            return $_self->notify($params['message'], compact('priority') + $options);
        };
    }

Usage Example

コード例 #1
0
ファイル: GrowlTest.php プロジェクト: unionofrad/lithium
 public function testMessagePriority()
 {
     $connection = fopen('php://memory', 'w+');
     $growl = new Growl(compact('connection') + array('name' => 'Lithium', 'title' => 'Lithium log'));
     $writer = $growl->write('info', 'info: Test message.', array());
     $params = array('message' => 'info: Test message.', 'options' => array('priority' => 'emergency'));
     $result = $writer('lithium\\analysis\\Logger', $params, null);
     $bytes = array(1, 0, 0, 7, 2, 2, 76, 105, 116, 104, 105, 117, 109, 0, 6, 69, 114, 114, 111, 114, 115, 0, 8, 77, 101, 115, 115, 97, 103, 101, 115, 0, 1, 126, 154, 165, 127, 162, 58, 0, 172, 243, 11, 201, 119, 62, 33, 133, 55, 1, 1, 0, 4, 0, 8, 0, 11, 0, 19, 0, 7, 77, 101, 115, 115, 97, 103, 101, 115, 76, 105, 116, 104, 105, 117, 109, 32, 108, 111, 103, 105, 110, 102, 111, 58, 32, 84, 101, 115, 116, 32, 109, 101, 115, 115, 97, 103, 101, 46, 76, 105, 116, 104, 105, 117, 109, 180, 219, 185, 111, 150, 248, 170, 144, 208, 88, 63, 48, 171, 130, 209, 32);
     rewind($connection);
     $result = array_map('ord', str_split(stream_get_contents($connection)));
     $this->assertEqual($bytes, $result);
 }
All Usage Examples Of lithium\analysis\logger\adapter\Growl::write