5 class File extends \Rsi\Fred\Log\Handler{
15 protected function format($prio,$context){
17 foreach($context as $key => $value)
if(strlen($result .= $key .
': ' . print_r($value,
true) .
"\n") > $this->maxSize){
24 public function add($prio,$message,$context){
25 if($this->filename)
try{
27 '*date/time' => $this->_lastInsertTime = date($this->dateTimeFormat),
28 '*message' => $message,
31 if(!\Rsi::commandLine()){
32 if($user_agent = $this->_log->component(
'client')->userAgent) $context = [
'*user agent' => $user_agent] + $context;
34 '*request' => $_SERVER[
'REQUEST_METHOD'] .
' ' . $_SERVER[
'REQUEST_URI'] .
' ' . $_SERVER[
'SERVER_PROTOCOL'],
35 '*remote addr' => $_SERVER[
'REMOTE_ADDR'],
36 '*started' => date($this->dateTimeFormat,$this->_log->fred->startTime)
39 \Rsi\File::mkdir(\
Rsi\File::dirname($this->filename));
40 \Rsi\File::write($this->filename,$this->
format($prio,$context),0666,
true);
43 if($this->_log->fred->debug)
throw $e;
52 foreach([60,3600,86400] as $delta)
if(($next = \
Rsi\Str::replaceDate($this->
format,$time + $delta)) != $this->filename){
53 \Rsi\File::unlink($next);
60 if($this->_filename === null){
61 $this->_filename = $this->_config[
'filename'] ?? null;
62 if(!$this->_filename) $this->_filename = \Rsi\Str::replaceDate($this->
format);
deleteNext()
Delete the file for the next period (when rotating logs).
add($prio, $message, $context)