You can create your own CakeLog class, and it will be automatically used. In this class you can do whatever you like, including discarding messages based upon their level. Of course you will still have the overhead of the function call, but you won't fill up your logs with needless information.
Below is the contents of my app/vendors/logs/detailed_log.php, which I require in the app/config/bootstrap.php. This is a modified version of RosSoft's logger ( http://rossoft.wordpress.com/2006/06/14/logging-with-source-object-name-and-function/ ), and includes the filename, line, class and function of the log call. class CakeLog { /** * Writes given message to a log file in the logs directory. * Puts the calling function name * * @param string $type Type of log, becomes part of the log's filename * @param string $msg Message to log * @return boolean Success */ function write($type, $msg) { if (!class_exists('File')) { uses('file'); } $filename=LOGS . $type . '.log'; $caller = backtrace_log(); $output=date('y-m-d H:i:s') . ' ('.getMicrotime().') [ ' . @ $caller['place'] . ' ' . @$caller['name'] . ' ] ' . ucfirst($type) . ': ' . "\n" . $msg . "\n"; $log=new File($filename); return $log->append($output); } } function backtrace_log () { $trace = debug_backtrace(); $output = array(); for ($step_index = 0; $step_index < sizeof($trace); $step_index++) { $step = $trace[$step_index]; // look for the "log" function call, or the "debug_backtrace" $funct = @$step['function']; if ( ($funct == 'debug_backtrace') or ( $funct == 'log' and ! empty($step['file']) ) ) { // get the actual function from the next one $funct = @$trace[$step_index+1]['function']; // get the rest of the details from this one $file = @$step['file']; $line = @$step['line']; // php5 may report the 'class' as Object, but have the calling instance in 'object' if (isset($step['object']) && is_object($step['object'])) { $class = get_class($step['object']); } else { $class = @$step['class']; } $type = @$step['type']; // name is the class, type and function $name = $class? $class.$type.$funct.'()': $funct.'()'; // place is a relative filename and line $place = str_replace(ROOT, '', $file).':'.$line; $output = array( 'file' => $file, 'line' => $line, 'class' => $class, 'type' => $type, 'funct' => $funct, 'name' => $name, 'place' => $place ); return $output; } } return $output; } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
