SilverStripe 3.0 API Docs
  • Package
  • Class
  • Tree
  • Deprecated
Version: master
  • master
  • 3.1
  • 3.0
  • 2.4
  • tagfield

Packages

  • cms
    • assets
    • batchaction
    • batchactions
    • content
    • control
    • controller
    • controllers
    • core
    • export
    • filesystem
    • forms
    • model
    • publishers
    • reports
    • search
    • security
    • tasks
  • forms
    • actions
    • core
    • fields-basic
    • fields-dataless
    • fields-datetime
    • fields-files
    • fields-formattedinput
    • fields-relational
    • fields-structural
    • transformations
    • validators
  • framework
    • admin
    • bulkloading
    • control
    • core
    • cron
    • dev
    • email
    • fields-formattedinput
    • fields-relational
    • filesystem
    • formatters
    • forms
    • gridfield
    • i18n
    • injector
    • integration
    • manifest
    • misc
    • model
    • parsers
    • search
    • security
    • tasks
    • testing
    • validation
    • view
  • None
  • PHP

Classes

  • BuildTask
  • CliDebugView
  • Debug
  • DebugView
  • Deprecation
  • DevelopmentAdmin
  • MigrationTask
  • PhpUnitWrapper
  • PhpUnitWrapper_3_4
  • PhpUnitWrapper_3_5
  • SapphireREPL
  • SS_Backtrace
  • SS_Cli
  • SS_Log
  • SS_LogEmailWriter
  • SS_LogErrorEmailFormatter
  • SS_LogErrorFileFormatter
  • SS_LogFileWriter
  • SS_SysLogWriter
  • SS_ZendLog
  • TaskRunner

Interfaces

  • IPhpUnitWrapper

Exceptions

  • PhpUnitWrapper_Exception

Functions

  • fileExistsInIncludePath

Class SS_Log

Wrapper class for a logging handler like Zend_Log which takes a message (or a map of context variables) and sends it to one or more Zend_Log_Writer_Abstract subclasses for output.

These priorities are currently supported: - SS_Log::ERR - SS_Log::WARN - SS_Log::NOTICE

You can add an error writer by calling SS_Log::add_writer()

Example usage of logging errors by email notification:

SS_Log::add_writer(new SS_LogEmailWriter('my@email.com'), SS_Log::ERR);

Example usage of logging errors by file:

SS_Log::add_writer(new SS_LogFileWriter('/var/log/silverstripe/errors.log'), SS_Log::ERR);

Example usage of logging at warnings and errors by setting the priority to '<=':

SS_Log::add_writer(new SS_LogEmailWriter('my@email.com'), SS_Log::WARN, '<=');

Each writer object can be assigned a formatter. The formatter is responsible for formatting the message before giving it to the writer. SS_LogErrorEmailFormatter is such an example that formats errors into HTML for human readability in an email client.

Formatters are added to writers like this:

$logEmailWriter = new SS_LogEmailWriter('my@email.com');
$myEmailFormatter = new MyLogEmailFormatter();
$logEmailWriter->setFormatter($myEmailFormatter);
Package: framework\dev
Located at sapphire/dev/Log.php

Methods summary

public static object
# get_logger( )

Get the logger currently in use, or create a new one if it doesn't exist.

Get the logger currently in use, or create a new one if it doesn't exist.

Returns

object
public static array
# get_writers( )

Get all writers in use by the logger.

Get all writers in use by the logger.

Returns

array
Collection of Zend_Log_Writer_Abstract instances
public static
# clear_writers( )

Remove all writers currently in use.

Remove all writers currently in use.

public static
# remove_writer( object $writer )

Remove a writer instance from the logger.

Remove a writer instance from the logger.

Parameters

$writer
object
$writer Zend_Log_Writer_Abstract instance
public static
# add_writer( object $writer, const $priority = null, mixed $comparison = '=' )

Add a writer instance to the logger.

Add a writer instance to the logger.

Parameters

$writer
object
$writer Zend_Log_Writer_Abstract instance
$priority
const
$priority Priority. Possible values: SS_Log::ERR, SS_Log::WARN or SS_Log::NOTICE
$comparison
mixed
$comparison Priority comparison operator. Acts on the integer values of the error levels, where more serious errors are lower numbers. By default this is "=", which means only the given priority will be logged. Set to "<=" if you want to track errors of at least the given priority.
public static
# log( mixed $message, const $priority, mixed $extras = null )

Dispatch a message by priority level.

Dispatch a message by priority level.

The message parameter can be either a string (a simple error message), or an array of variables. The latter is useful for passing along a list of debug information for the writer to handle, such as error code, error line, error context (backtrace).

Parameters

$message
mixed
$message Exception object or array of error context variables
$priority
const
$priority Priority. Possible values: SS_Log::ERR, SS_Log::WARN or SS_Log::NOTICE
$extras
mixed
$extras Extra information to log in event

Magic methods summary

Constants summary

string ERR Zend_Log::ERR
#
string WARN Zend_Log::WARN
#
string NOTICE Zend_Log::NOTICE
#

Properties summary

public static string $logger_class
#

Logger class to use.

Logger class to use.

See

SS_Log::get_logger()
protected static object $logger
#

See

SS_Log::get_logger()
public static array $log_globals
#

Logs additional context from PHP's superglobals. Caution: Depends on logger implementation (mainly targeted at SS_LogEmailWriter).

Logs additional context from PHP's superglobals. Caution: Depends on logger implementation (mainly targeted at SS_LogEmailWriter).

See

http://framework.zend.com/manual/en/zend.log.overview.html#zend.log.overview.understanding-fields

Comments

Comment policy: Please use comments for tips and corrections about the described functionality. Comments are moderated, we reserve the right to remove comments that are inappropriate or are no longer relevant.
Use the Silverstripe Forum to ask questions.
blog comments powered by Disqus
SilverStripe 3.0 API Docs API documentation generated by ApiGen 2.8.0