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 /* $Id: LogRecord.class.php 4687 2007-12-09 18:57:18Z voxus $ */
00012 
00016     final class LogRecord
00017     {
00018         private $message    = null;
00019         private $level      = LogLevel::INFO;
00020         
00021         private $date       = null;
00022         
00023         public function __construct()
00024         {
00025             $this->date = Timestamp::makeNow();
00026         }
00027         
00031         public static function create()
00032         {
00033             return new self;
00034         }
00035         
00039         public function setMessage($message)
00040         {
00041             Assert::isString($message);
00042             
00043             $this->message = $message;
00044             
00045             return $this;
00046         }
00047         
00048         public function getMessage()
00049         {
00050             return $this->message;
00051         }
00052         
00056         public function setDate(Timestamp $date)
00057         {
00058             $this->date = $date;
00059             
00060             return $this;
00061         }
00062         
00066         public function getDate()
00067         {
00068             return $this->date;
00069         }
00070         
00074         public function setLevel(LogLevel $level)
00075         {
00076             $this->level = $level;
00077             
00078             return $this;
00079         }
00080         
00084         public function getLevel()
00085         {
00086             return $this->level;
00087         }
00088         
00094         public function toString()
00095         {
00096             return sprintf(
00097                 '%s %2s %s %s: %s',
00098                 date('M', $this->date->toStamp()), $this->date->getDay(),
00099                 $this->date->toTime(':', ':'),
00100                 $this->level->getName(),
00101                 $this->message
00102             );
00103         }
00104     }
00105 ?>

Generated on Sun Dec 9 21:56:24 2007 for onPHP by  doxygen 1.5.4