lithium\analysis\Logger::write()
Writes a message to one or more log adapters, where the adapters that are written to are the ones that respond to the given priority level.
Parameters
-
string
$priorityThe priority of the log message to be written.
-
string
$messageThe message to be written.
-
array
$optionsAn array of adapter-specific options that may be passed when writing log messages. Some options are also handled by
Loggeritself:'name'string: This option can be specified if you wish to write to a specific adapter configuration, instead of writing to the adapter(s) that respond to the given priority.
Returns
booleanReturns true if all log writes succeeded, or false if any or all writes
failed.
Filter
This method can be filtered.
Source
public static function write($priority, $message, array $options = []) {
$defaults = ['name' => null];
$options += $defaults;
$result = true;
if (isset(static::$_configurations[$options['name']])) {
$name = $options['name'];
$methods = [$name => static::adapter($name)->write($priority, $message, $options)];
} elseif (!isset(static::$_priorities[$priority])) {
$message = "Attempted to write log message with invalid priority `{$priority}`.";
throw new UnexpectedValueException($message);
} else {
$methods = static::_configsByPriority($priority, $message, $options);
}
foreach ($methods as $name => $method) {
$params = compact('priority', 'message', 'options');
$config = static::_config($name);
if (!empty($config['filters'])) {
$message = 'Per adapter filters have been deprecated. Please ';
$message .= "filter the manager class' static methods instead.";
trigger_error($message, E_USER_DEPRECATED);
$r = Filters::bcRun(
get_called_class(), __FUNCTION__, $params, $method, $config['filters']
);
} else {
$r = Filters::run(get_called_class(), __FUNCTION__, $params, $method);
}
if (!$r) {
$result = false;
}
}
return $methods ? $result : false;
}