app\extensions\adapter\logger \ Growl

Growl Logger Adapter

Download |
| Newest | Edit
<?php
/**
 * Lithium: the most rad php framework
 *
 * @copyright     Copyright 2010, Union of RAD (http://union-of-rad.org)
 * @license       http://opensource.org/licenses/bsd-license.php The BSD License
 */

namespace app\extensions\adapter\logger;

class Growl extends \lithium\core\Object {

	protected $growl = null;

	/**
	 * Class constructor.
	 *
	 * @param array $config
	 * @return void
	 */
	public function __construct(array $config = array()) {
		parent::__construct($config);

		// fugly:
		@require_once 'Net/Growl.php';
		if (class_exists('\\Net_Growl')) {
			$notifications = array('Errors', 'Messages');
			$app = 'Lithium';
			$this->growl = new \Net_Growl($app, $notifications);
		}
	}

	/**
	 * Appends $data to file $type.
	 *
	 * @param string $type
	 * @param string $message
	 * @return boolean `True` on successful write, `false` otherwise.
	 */
	public function write($type, $message) {
		if (!$this->growl) {
			return function() {};
		}
		$growl = $this->growl;
		return function($self, $params, $chain) use ($growl) {
			$growl->notify(
				'Messages',
				'Lithium log',
				"{$params['type']}: {$params['message']}"
			);
			return true;
		};
	}
}

?>

Description

Logger adapter to do Growl notifications. You need Net_Growl from PEAR (http://pear.php.net/package/Net_Growl); `pear install Net_Growl-beta` Also: Net_Growl is crappy PHP 4 code. That's why there's the noted fugly @require_once. You shouldn't do this in real life.

Details

  • Version: 1
  • Created: 2010-04-16 03:21:48
  • File: app/extensions/adapter/logger/Growl.php

Maintainers