mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 19:38:26 +00:00
da79dff7d7
- Dispatcher sets a Controller::here variable with the real URL used to access the page, so that tag generators can that use an url (linkTo and formTag for example) use the real url, not guess it from the controller and action names which often fails - Log class works more reliably and a LogError() shortcut function was added - Nstring class added, to store string-related functions (there are just four yet, including a random password generator and an string-to-array splitter - SimpleTest library (with Rephlux) included in /vendors; I've tweaked SimpleScorer::inCli() function, because it didn't work on my setup, it should work everywhere now (it checks for empty REQUEST_METHOD, which should only be empty in CLI) git-svn-id: https://svn.cakephp.org/repo/trunk/cake@248 3807eeeb-6ff5-0310-8944-8be069107fe0
71 lines
No EOL
2 KiB
PHP
71 lines
No EOL
2 KiB
PHP
<?PHP
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// + $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 + //
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
/**
|
|
* 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
|
|
*/
|
|
class Log
|
|
{
|
|
function write($type, $msg)
|
|
{
|
|
$out = date('y-m-d H:i:s').' '.ucfirst($type).': '.$msg."\n";
|
|
$fn = LOGS.$type.'.log';
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Error constant. Used for differentiating error logging and debugging.
|
|
*
|
|
*/
|
|
define ('LOG_ERROR', 2);
|
|
|
|
/**
|
|
* Shortcut.
|
|
*/
|
|
function LogError ($message)
|
|
{
|
|
$bad = array("\n", "\r", "\t");
|
|
$good = ' ';
|
|
Log::write('error', str_replace($bad, $good, $message));
|
|
}
|
|
|
|
?>
|