Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
49 lines (42 sloc) 1.15 KB
<?php
/**
* Lithium: the most rad php framework
*
* @copyright Copyright 2009, Union of RAD (http://union-of-rad.org)
* @license http://opensource.org/licenses/bsd-license.php The BSD License
*/
namespace lithium\util\audit\logger\adapters;
use \lithium\util\String;
use \lithium\storage\Cache as Writer;
class Cache extends \lithium\core\Object {
/**
* Class constructor
*
* @return void
*/
public function __construct($config = array()) {
$defaults = array(
'config' => null,
'expiry' => '+999 days',
'key' => 'log_{:type}_{:timestamp}'
);
parent::__construct($config + $defaults);
}
/**
* Appends `$data` to file `$type`.
*
* @param string $type
* @param string $message
* @return boolean True on successful write, false otherwise
*/
public function write($type, $message) {
$config = $this->_config;
return function($self, $params, $chain) use ($config) {
$params += array('timestamp' => strtotime('now'));
$key = $config['key'];
$key = is_callable($key) ? $key($params) : String::insert($key, $params);
Writer::write($config['config'], $key, $params['message'], $config['expiry']);
};
}
}
?>
Jump to Line
Something went wrong with that request. Please try again.