PHP Class lithium\analysis\logger\adapter\Growl

Inheritance: extends lithium\core\Object
显示文件 Open project: unionofrad/lithium Class Usage Examples

Protected Properties

Property Type Description
$_autoConfig array Allow the Growl connection resource to be auto-configured from constructor parameters.
$_connection resource Holds the connection resource used to send messages to Growl.
$_priorities array Array that maps Logger message priority names to Growl-compatible priority levels.
$_registered boolean Registration only needs to happen once, but may fail for several reasons, including inability to connect to the server, or the server requires a password which has not been specified.

Public Methods

Method Description
__construct ( array $config = [] ) : void Constructor. Growl logger constructor. Accepts an array of settings which are merged with the default settings and used to create the connection and handle notifications.
__destruct ( ) : void Destructor. Closes and releases the socket connection to Growl.
notify ( string $description = '', array $options = [] ) : boolean Posts a new notification to the Growl server.
write ( string $priority, string $message, array $options = [] ) : Closure Writes $message to a new Growl notification.

Protected Methods

Method Description
_connection ( ) : resource Creates a connection to the Growl server using the protocol, host and port configurations specified in the constructor.
_register ( ) : boolean Growl server connection registration and initialization.
_send ( string $data ) : boolean Sends binary data to the Growl server.

Method Details

__construct() public method

Constructor. Growl logger constructor. Accepts an array of settings which are merged with the default settings and used to create the connection and handle notifications.
See also: lithium\analysis\Logger::write()
public __construct ( array $config = [] ) : void
$config array The settings to configure the logger. Available settings are as follows: - `'name`' _string_: The name of the application as it should appear in Growl's system settings. Defaults to the directory name containing your application. - `'host'` _string_: The Growl host with which to communicate, usually your local machine. Use this setting to send notifications to another machine on the network. Defaults to `'127.0.0.1'`. - `'port'` _integer_: Port of the host machine. Defaults to the standard Growl port, `9887`. - `'password'` _string_: Only required if the host machine requires a password. If notification or registration fails, check this against the host machine's Growl settings. - '`protocol'` _string_: Protocol to use when opening socket communication to Growl. Defaults to `'udp'`. - `'title'` _string_: The default title to display when showing Growl messages. The default value is the same as `'name'`, but can be changed on a per-message basis by specifying a `'title'` key in the `$options` parameter of `Logger::write()`. - `'notification'` _array_: A list of message types you wish to register with Growl to be able to send. Defaults to `array('Errors', 'Messages')`.
return void

__destruct() public method

Destructor. Closes and releases the socket connection to Growl.
public __destruct ( ) : void
return void

_connection() protected method

Creates a connection to the Growl server using the protocol, host and port configurations specified in the constructor.
protected _connection ( ) : resource
return resource Returns a connection resource created by `fsockopen()`.

_register() protected method

Growl server connection registration and initialization.
protected _register ( ) : boolean
return boolean True

_send() protected method

Sends binary data to the Growl server.
protected _send ( string $data ) : boolean
$data string The raw binary data to send to the Growl server.
return boolean Always returns `true`.

notify() public method

Posts a new notification to the Growl server.
public notify ( string $description = '', array $options = [] ) : boolean
$description string Message to be displayed.
$options array Options consists of: -'title': The title of the displayed notification. Displays the name of the application's parent folder by default.
return boolean Always returns `true`.

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.

Property Details

$_autoConfig protected_oe property

Allow the Growl connection resource to be auto-configured from constructor parameters.
protected array $_autoConfig
return array

$_connection protected_oe property

Holds the connection resource used to send messages to Growl.
protected resource $_connection
return resource

$_priorities protected_oe property

Array that maps Logger message priority names to Growl-compatible priority levels.
protected array $_priorities
return array

$_registered protected_oe property

Registration only needs to happen once, but may fail for several reasons, including inability to connect to the server, or the server requires a password which has not been specified.
protected bool $_registered
return boolean