cake_log.php

Go to the documentation of this file.
00001 <?php
00002 /* SVN FILE: $Id: cake__log_8php-source.html 675 2008-12-26 00:27:14Z gwoo $ */
00003 /**
00004  * Logging.
00005  *
00006  * Log messages to text files.
00007  *
00008  * PHP versions 4 and 5
00009  *
00010  * CakePHP(tm) :  Rapid Development Framework <http://www.cakephp.org/>
00011  * Copyright 2005-2008, Cake Software Foundation, Inc.
00012  *                              1785 E. Sahara Avenue, Suite 490-204
00013  *                              Las Vegas, Nevada 89104
00014  *
00015  * Licensed under The MIT License
00016  * Redistributions of files must retain the above copyright notice.
00017  *
00018  * @filesource
00019  * @copyright       Copyright 2005-2008, Cake Software Foundation, Inc.
00020  * @link                http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
00021  * @package         cake
00022  * @subpackage      cake.cake.libs
00023  * @since           CakePHP(tm) v 0.2.9
00024  * @version         $Revision: 675 $
00025  * @modifiedby      $LastChangedBy: gwoo $
00026  * @lastmodified    $Date: 2008-12-25 16:27:14 -0800 (Thu, 25 Dec 2008) $
00027  * @license         http://www.opensource.org/licenses/mit-license.php The MIT License
00028  */
00029 /**
00030  * Included libraries.
00031  *
00032  */
00033     if (!class_exists('File')) {
00034         uses('file');
00035     }
00036 /**
00037  * Logs messages to text files
00038  *
00039  * @package     cake
00040  * @subpackage  cake.cake.libs
00041  */
00042 class CakeLog{
00043 /**
00044  * Writes given message to a log file in the logs directory.
00045  *
00046  * @param string $type Type of log, becomes part of the log's filename
00047  * @param string $msg  Message to log
00048  * @return boolean Success
00049  */
00050     function write($type, $msg) {
00051         $filename = LOGS . $type . '.log';
00052         $output = date('Y-m-d H:i:s') . ' ' . ucfirst($type) . ': ' . $msg . "\n";
00053         $log = new File($filename);
00054         return $log->append($output);
00055     }
00056 }
00057 ?>