# LogRecord.class.php

Go to the documentation of this file.

    00001 <?php
    00002 /***************************************************************************
    00003  *   Copyright (C) 2007 by Ivan Y, Khvostishkov, Denis M. Gabaidulin       *
    00004  *                                                                         *
    00005  *   This program is free software; you can redistribute it and/or modify  *
    00006  *   it under the terms of the GNU Lesser General Public License as        *
    00007  *   published by the Free Software Foundation; either version 3 of the    *
    00008  *   License, or (at your option) any later version.                       *
    00009  *                                                                         *
    00010  ***************************************************************************/
    00011
    00015     final class LogRecord
    00016     {
    00017         private $message    = null;
    00018         private $level      = LogLevel::INFO;
    00019
    00020         private $date       = null;
    00021
    00022         public function __construct()
    00023         {
    00024             $this->date = Timestamp::makeNow();
    00025         }
    00026
    00030         public static function create()
    00031         {
    00032             return new self;
    00033         }
    00034
    00038         public function setMessage($message)
    00039         {
    00040             Assert::isString($message);
    00041
    00042             $this->message = $message;
    00043
    00044             return $this;
    00045         }
    00046
    00047         public function getMessage()
    00048         {
    00049             return $this->message;
    00050         }
    00051
    00055         public function setDate(Timestamp $date)
    00056         {
    00057             $this->date = $date;
    00058
    00059             return $this;
    00060         }
    00061
    00065         public function getDate()
    00066         {
    00067             return $this->date;
    00068         }
    00069
    00073         public function setLevel(LogLevel $level)
    00074         {
    00075             $this->level = $level;
    00076
    00077             return $this;
    00078         }
    00079
    00083         public function getLevel()
    00084         {
    00085             return $this->level;
    00086         }
    00087
    00093         public function toString()
    00094         {
    00095             return sprintf(
    00096                 '%s %2s %s %s: %s',
    00097                 date('M', $this->date->toStamp()), $this->date->getDay(),
    00098                 $this->date->toTime(':', ':'),
    00099                 $this->level->getName(),
    00100                 $this->message
    00101             );
    00102         }
    00103     }
    00104 ?>