Modules

abstract Kohana_Log_Writer

This class is a transparent base class for Log_Writer and should not be accessed directly.

Log writer abstract class. All Log writers must extend this class.

package
Kohana
category
Logging
author
Kohana Team
copyright
© 2008-2012 Kohana Team
license
https://kohana.top/license

Class declared in SYSPATH/classes/Kohana/Log/Writer.php on line 12.

Properties

public static int $strace_level

Level to use for stack traces

integer 7

public static string $timestamp

timestamp format for log entries.

Defaults to Date::$timestamp_format

NULL

public static string $timezone

timezone for log entries

Defaults to Date::$timezone, which defaults to date_default_timezone_get()

NULL

protected array $_log_levels

Numeric log level to string lookup table.

Default value:
array(8) (
    0 => string(9) "EMERGENCY"
    1 => string(5) "ALERT"
    2 => string(8) "CRITICAL"
    3 => string(5) "ERROR"
    4 => string(7) "WARNING"
    5 => string(6) "NOTICE"
    6 => string(4) "INFO"
    7 => string(5) "DEBUG"
)

Methods

final public __toString( ) (defined in Kohana_Log_Writer)

Allows the writer to have a unique key when stored.

echo $writer;

Return Values

  • string

Source Code

final public function __toString()
{
    return spl_object_hash($this);
}

public format_message( array $message [, string $format = string(33) "time --- level: body in file:line" ] ) (defined in Kohana_Log_Writer)

Formats a log entry.

Parameters

  • array $message required - $message
  • string $format = string(33) "time --- level: body in file:line" - $format

Return Values

  • string

Source Code

public function format_message(array $message, $format = "time --- level: body in file:line")
{
    $message['time'] = Date::formatted_time('@' . $message['time'], Log_Writer::$timestamp, Log_Writer::$timezone, true);
    $message['level'] = $this->_log_levels[$message['level']];

    $string = strtr($format, array_filter($message, 'is_scalar'));

    if (isset($message['additional']['exception'])) {
        // Re-use as much as possible, just resetting the body to the trace
        $message['body'] = $message['additional']['exception']->getTraceAsString();
        $message['level'] = $this->_log_levels[Log_Writer::$strace_level];

        $string .= PHP_EOL . strtr($format, array_filter($message, 'is_scalar'));
    }

    return $string;
}

abstract public write( array $messages ) (defined in Kohana_Log_Writer)

Write an array of messages.

$writer->write($messages);

Parameters

  • array $messages required - $messages

Return Values

  • void

Source Code

abstract public function write(array $messages);