PHP Class Scalr\LogCollector\AbstractLogger

Author: Constantine Karnacvevych ([email protected])
显示文件 Open project: scalr/scalr Class Usage Examples

Protected Properties

Property Type Description
$defaultTag string Default tag to send
$enabled boolean Indicates whether logging is enabled
$subscribers array Event subscribers
$writer Scalr\LogCollector\Writers\AbstractWriter A backend writer

Public Methods

Method Description
__construct ( array $config ) Constructor. Instantiates AbstractLogger, prepares backend
getTimestamp ( integer $time = null ) : string Gets current timestamp in common format.
isEnabled ( ) : boolean Returns whether logger is enabled
log ( string $event, variadic $extra ) : boolean Logs event to a specified backend
setIsEnabled ( boolean $isEnabled = null ) : AbstractLogger Set is enabled logger

Protected Methods

Method Description
getCommonData ( ) : array Prepares extra data to pass to a backend
initializeSubscribers ( ) Initializes Event subscribers
setWriter ( array $config ) : AbstractLogger Set writer to AbstractLogger

Private Methods

Method Description
validateConfig ( array $config ) Validates configuration options

Method Details

__construct() public method

Constructor. Instantiates AbstractLogger, prepares backend
public __construct ( array $config )
$config array Logger configuration

getCommonData() protected method

Prepares extra data to pass to a backend
protected getCommonData ( ) : array
return array Prepared extra data for logging

getTimestamp() public static method

Gets current timestamp in common format.
public static getTimestamp ( integer $time = null ) : string
$time integer Unix timestamp
return string Returns current timestamp in the server time zone.

initializeSubscribers() protected method

The use of the subscribers is to transform object to array
protected initializeSubscribers ( )

isEnabled() public method

Returns whether logger is enabled
public isEnabled ( ) : boolean
return boolean true if logger enabled, else - false

log() public method

Logs event to a specified backend
public log ( string $event, variadic $extra ) : boolean
$event string Event tag
$extra variadic optional Extra data to pass.
return boolean Indicates whether operation was successful

setIsEnabled() public method

Set is enabled logger
public setIsEnabled ( boolean $isEnabled = null ) : AbstractLogger
$isEnabled boolean Whether logger is enabled
return AbstractLogger

setWriter() protected method

Set writer to AbstractLogger
protected setWriter ( array $config ) : AbstractLogger
$config array Accepted keys are: proto, path, port, and timeout
return AbstractLogger

Property Details

$defaultTag protected_oe property

Default tag to send
protected string $defaultTag
return string

$enabled protected_oe property

Indicates whether logging is enabled
protected bool $enabled
return boolean

$subscribers protected_oe property

Event subscribers
protected array $subscribers
return array

$writer protected_oe property

A backend writer
protected AbstractWriter,Scalr\LogCollector\Writers $writer
return Scalr\LogCollector\Writers\AbstractWriter