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. (https://cakefoundation.org)
License: MIT License
Location: Cake/Log/Engine/SyslogLog.php

Properties summary

  • $_defaults protected
    array

    By default messages are formatted as: type: message

  • $_open protected
    boolean
    Whether the logger connection is open or not
  • $_priorityMap protected
    array
    Used to map the string names back to their LOG_* constants

Inherited Properties

Method Summary

  • __construct() public

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

  • __destruct() public
    Closes the logger connection
  • _open() protected

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

  • _write() protected

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

  • write() public
    Writes a message to syslog

Method Detail

__construct()source 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()

__destruct()source public

__destruct( )

Closes the logger connection

_open()source 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

_write()source 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

write()source 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

config()source 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

Properties detail

$_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
)

© 2005–2017 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.
https://api.cakephp.org/2.10/class-SyslogLog.html