<?php
/**
 * This file is part of the Logger library and defines the {@link Message} class.
 * 
 * @author Sylvain Lequeux
 * @author Francois Daoust <fd@w3.org>
 * @package Logger
 * @version $Revision: 1.4 $
 * @license http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231.html W3C Software Notice and License
 * @copyright Copyright (c) 2009, W3C (MIT, ERCIM, Keio)
 */


/**
 * Message objects are returned by the {@link Logger::retrieve_messages()} method,
 * and contain information about the logged message, such as the date when the
 * message was logged and the message's level.
 * 
 * @author Sylvain Lequeux
 * @author Francois Daoust <fd@w3.org>
 * @package Logger
 * @version $Revision: 1.4 $
 * @license http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231.html W3C Software Notice and License
 * @copyright Copyright (c) 2009, W3C (MIT, ERCIM, Keio)
 *
 */
class Message{
	/**
	 * @var string The level of the message
	 */
	private $level;
	/**
	 * @var Date The date the message was logged.
	 */
	private $date;
	/**
	 * @var string The message in itself.
	 */
	private $content;
	
	/**
	 * Builds a Message object.
	 * 
	 * The message's date is set to current date and time.
	 * 
	 * @param string $message_content The message in itself.
	 * @param string $message_level The level of the message.
	 */
	function __construct($message_content, $message_level){
		$this->level = $message_level;
		$this->content = $message_content;
		$this->date = date('r');
	}
	
	/**
	 * Returns the level of the message.
	 * 
	 * @return the level of the message.
	 */
	function get_level(){
		return $this->level;
	}
	
	/**
	 * Changes the date the message was created.
	 * 
	 * The method should typically be used when messages are
	 * retrieved using the {@link Logger::retrieve_messages()} method.
	 * 
	 * @param Date $date the new date.
	 */
	function set_date($date){
		$this->date = $date;
	}
	
	/**
	 * Returns the message as a string, creation date and message level excluded.
	 * 
	 * @return String The message in itself.
	 */
	function get_message(){
		return $this->date . ' : ' . $this->content;
	}
}

?>