SyslogLog (class)

Class SyslogLog

Syslog stream for Logging. Writes logs to the system logger

BaseLog implements CakeLogInterface
Extended by SyslogLog
Package: Cake\Log\Engine
Copyright: Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
License: MIT License
Located at Cake/Log/Engine/SyslogLog.php

Method Detail

__constructsource public

__construct( array $config array() )

Make sure the configuration contains the format parameter, by default it uses the error number and the type as a prefix to the message

Parameters

array $config optional array()
Options list.

Overrides

BaseLog::__construct()

__destructsource public

__destruct( )

Closes the logger connection

_opensource protected

_open( string $ident , integer $options , integer $facility )

Extracts the call to openlog() in order to run unit tests on it. This function will initialize the connection to the system logger

Parameters

string $ident
the prefix to add to all messages logged
integer $options
the options flags to be used for logged messages
integer $facility
the stream or facility to log to

_writesource protected

_write( integer $priority , string $message )

Extracts the call to syslog() in order to run unit tests on it. This function will perform the actual write in the system logger

Parameters

integer $priority
Message priority.
string $message
Message to log.

Returns

boolean
bool

writesource public

write( string $type , string $message )

Writes a message to syslog

Map the $type back to a LOG_ constant value, split multi-line messages into multiple log messages, pass all messages through the format defined in the configuration

Parameters

string $type
The type of log you are making.
string $message
The message you want to log.

Returns

boolean
success of write.

Methods inherited from BaseLog

configsource public

config( array $config array() )

Sets instance config. When $config is null, returns config array

Config

  • types string or array, levels the engine is interested in
  • scopes string or array, scopes the engine is interested in

Parameters

array $config optional array()
engine configuration

Returns

array
array

Properties summary

$_defaultssource

protected array

By default messages are formatted as: type: message

To override the log format (e.g. to add your own info) define the format key when configuring this logger

If you wish to include a prefix to all messages, for instance to identify the application or the web server, then use the prefix option. Please keep in mind the prefix is shared by all streams using syslog, as it is dependent of the running process. For a local prefix, to be used only by one stream, you can use the format key.

Example:

CakeLog::config('error', array(
        'engine' => 'Syslog',
        'types' => array('emergency', 'alert', 'critical', 'error'),
        'format' => "%s: My-App - %s",
        'prefix' => 'Web Server 01'
));
array(
    'format' => '%s: %s',
    'flag' => LOG_ODELAY,
    'prefix' => '',
    'facility' => LOG_USER
)

$_opensource

protected boolean

Whether the logger connection is open or not

false

$_priorityMapsource

protected array

Used to map the string names back to their LOG_* constants

array(
    'emergency' => LOG_EMERG,
    'alert' => LOG_ALERT,
    'critical' => LOG_CRIT,
    'error' => LOG_ERR,
    'warning' => LOG_WARNING,
    'notice' => LOG_NOTICE,
    'info' => LOG_INFO,
    'debug' => LOG_DEBUG
)

Properties inherited from BaseLog

$_configsource

protected string

Engine config

array()

© 2005–2016 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
http://api.cakephp.org/2.7/class-SyslogLog.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部