2005-05-21 22:40:51 +00:00
|
|
|
<?PHP
|
2005-05-21 22:51:26 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// + $Id $
|
|
|
|
// +------------------------------------------------------------------+ //
|
|
|
|
// + Cake <https://developers.nextco.com/cake/> + //
|
|
|
|
// + Copyright: (c) 2005, Cake Authors/Developers + //
|
|
|
|
// + Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com> + //
|
|
|
|
// + Larry E. Masters aka PhpNut <nut@phpnut.com> + //
|
|
|
|
// + Kamil Dzielinski aka Brego <brego.dk@gmail.com> + //
|
|
|
|
// +------------------------------------------------------------------+ //
|
|
|
|
// + Licensed under The MIT License + //
|
|
|
|
// + Redistributions of files must retain the above copyright notice. + //
|
|
|
|
// + See: http://www.opensource.org/licenses/mit-license.php + //
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
2005-05-21 22:40:51 +00:00
|
|
|
|
2005-05-21 22:51:26 +00:00
|
|
|
/**
|
|
|
|
* Purpose: Log
|
|
|
|
* Logs messages to text files.
|
|
|
|
*
|
|
|
|
* @filesource
|
|
|
|
* @author Cake Authors/Developers
|
|
|
|
* @copyright Copyright (c) 2005, Cake Authors/Developers
|
|
|
|
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
|
|
|
|
* @package cake
|
|
|
|
* @subpackage cake.libs
|
|
|
|
* @since Cake v 1.0.0.0
|
|
|
|
* @version $Revision$
|
|
|
|
* @modifiedby $LastChangedBy$
|
|
|
|
* @lastmodified $Date$
|
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
|
|
|
*/
|
2005-06-18 23:26:35 +00:00
|
|
|
class Log
|
|
|
|
{
|
|
|
|
function write($type, $msg)
|
|
|
|
{
|
|
|
|
$out = date('y-m-d H:i:s').' '.ucfirst($type).': '.$msg."\n";
|
2005-05-21 22:40:51 +00:00
|
|
|
$fn = LOGS.$type.'.log';
|
|
|
|
|
2005-06-18 23:26:35 +00:00
|
|
|
if (!($log = fopen($fn, 'a')))
|
|
|
|
{
|
|
|
|
print ("[Log] Could not open {$fn}!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!fwrite($log, $out))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!fclose($log))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
2005-05-21 22:40:51 +00:00
|
|
|
}
|
|
|
|
}
|
2005-06-18 23:26:35 +00:00
|
|
|
|
2005-06-02 19:37:06 +00:00
|
|
|
/**
|
|
|
|
* Error constant. Used for differentiating error logging and debugging.
|
|
|
|
*
|
|
|
|
*/
|
2005-05-21 22:51:26 +00:00
|
|
|
define ('LOG_ERROR', 2);
|
|
|
|
|
2005-06-18 23:26:35 +00:00
|
|
|
/**
|
|
|
|
* Shortcut.
|
|
|
|
*/
|
|
|
|
function LogError ($message)
|
|
|
|
{
|
|
|
|
$bad = array("\n", "\r", "\t");
|
|
|
|
$good = ' ';
|
|
|
|
Log::write('error', str_replace($bad, $good, $message));
|
|
|
|
}
|
|
|
|
|
2005-05-21 22:40:51 +00:00
|
|
|
?>
|