Library
Class

Library\Logger

class Logger extends AbstractLogger implements LoggerInterface

Write some log infos in log files

For compliance, this class implements the PSR Logger Interface.

Constants

EMERGENCY

ALERT

CRITICAL

ERROR

WARNING

NOTICE

INFO

DEBUG

Methods

__construct(array $user_options = array())

Creation of a new logger entry

bool log(int $level, string $message, array $context = array(), string $logname = null)

Logs with an arbitrary level.

__set(string $var, mixed $val)

Allows to set a property or a configuration entry like : $logger->config_name = $val

mixed __get(string $var)

Allows to call a configuration entry like : $logger->config_name

static array getOptions()

static string interpolate(string $message, array $context = array(), bool $silent = false)

Interpolates context values into the message placeholders.

static  getUserIp()

Get the user IP address

static string writeArray(array $array)

Write an array on one line

static string writeArrayItem(array $item)

Safely transform an array item in string

Details

at line 116
public __construct(array $user_options = array())

Creation of a new logger entry

Parameters

array $user_options A set of one shot options

See also

self::init()

at line 131
public bool log(int $level, string $message, array $context = array(), string $logname = null)

Logs with an arbitrary level.

Parameters

int $level A type for the message, must be a class constant
string $message The message info to log
array $context An optional context array for the message
string $logname A logfile name to write in a specific one

Return Value

bool

Exceptions

InvalidArgumentException if $level is unknown

at line 174
public __set(string $var, mixed $val)

Allows to set a property or a configuration entry like : $logger->config_name = $val

Parameters

string $var A property name or an entry of the $config class static
mixed $val The value to set

Exceptions

InvalidArgumentException if so

at line 192
public mixed __get(string $var)

Allows to call a configuration entry like : $logger->config_name

Parameters

string $var A property name or an entry of the $config class static

Return Value

mixed The value if found, null otherwise

at line 204
static public array getOptions()

Return Value

array

at line 219
static public string interpolate(string $message, array $context = array(), bool $silent = false)

Interpolates context values into the message placeholders.

Parameters

string $message The original message string, with placeholders constructed as {variable_name}
array $context The context where must be found the placeholders values
bool $silent Does the function must be silent or not ; if not, an Exception is thrown if one of the context array values can't be written as a string

Return Value

string The message with placeholders replacements

Exceptions

RuntimeException

at line 419
static public getUserIp()

Get the user IP address

at line 436
static public string writeArray(array $array)

Write an array on one line

Parameters

array $array

Return Value

string The formatted string

at line 455
static public string writeArrayItem(array $item)

Safely transform an array item in string

Parameters

array $item

Return Value

string The formatted string