#6280: Add conditional logging, LOG_LEVEL >= LOG_WARNING for production systems
--------------------------+-------------------------------------------------
Reporter: cuppett | Type: Enhancement
Status: new | Priority: Medium
Milestone: 1.2.x.x | Component: General
Version: 1.2 Final | Severity: Major
Keywords: | Php_version: n/a
Cake_version: 1.2.2 |
--------------------------+-------------------------------------------------
I noticed that there really isn't a way in cake_log.php to disable logging
under a certain threshold. This is a pretty big deal on busy production
systems to pound on LOG_DEBUG and debug.log and creates some I/O
contention where it really isn't necessary.
I modified CakeLog->write() to support this; however, I stripped out the
"you can use the number or the word" reverse lookup currently in there
since it was unnecessary for my code, but it's a start for how this could
be implemented. It basically checks the log level requested to write and
if it isn't <= a new constant LOG_LEVEL, it won't write.
{{{
function write($type, $msg) {
$levels = array(
LOG_WARNING => 'warning',
LOG_NOTICE => 'notice',
LOG_INFO => 'info',
LOG_DEBUG => 'debug',
LOG_ERR => 'error',
LOG_ERROR => 'error'
);
if (!is_int($type) || $type <= LOG_LEVEL) {
if (is_int($type) && isset($levels[$type])) {
$type = $levels[$type];
}
if ($type == 'error' || $type == 'warning') {
$filename = LOGS . 'error.log';
} else {
$filename = LOGS . 'debug.log';
}
$output = date('Y-m-d H:i:s') . ' ' .
ucfirst($type) . ': ' . $msg . "\n";
$log = new File($filename, true);
if ($log->writable()) {
return $log->append($output);
}
}
return true;
}
}}}
--
Ticket URL: <https://trac.cakephp.org/ticket/6280>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC.
Our primary goal is to provide a structured framework that enables PHP users at
all levels to rapidly develop robust web applications, without any loss to
flexibility.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"tickets cakephp" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---