Skip to content
Browse files

modified logic of adjust output level and README.md.

  • Loading branch information...
1 parent d73ceb3 commit fdc1a5cba7007695423d6ad397a02d7fcb80a246 @withelmo withelmo committed Jun 10, 2011
Showing with 37 additions and 7 deletions.
  1. +14 −2 README.md
  2. +23 −5 libs/log/rotate_file_log.php
View
16 README.md
@@ -49,7 +49,19 @@ Modify following,
### Usage ###
-add the following code of the level that you want to output the log in bootstrap.php.
+add the following code in bootstrap.php.
+
+ <?php
+ CakeLog::config('Yalog..OutputLevel', LOG_WARNING);
+
+set lower level than level that you want to output the log at.
+(LOG_ERROR:2 > LOG_WARNING:4 > LOG_NOTICE:5 > LOG_INFO:6 > LOG_DEBUG:7)
+
+In the example, log of "LOG_ERROR", "LOG_WARNING" and the others are output.
+
+All output is stopped when it is set to false.
<?php
- CakeLog::config('Yalog..OutputLevel', LOG_WARNING);
+ CakeLog::config('Yalog..OutputLevel', false);
+
+
View
28 libs/log/rotate_file_log.php
@@ -75,10 +75,28 @@ function write($type, $message) {
return true;
}
+ /**
+ * _checkLogOutputLevel
+ * check level of log output
+ * Compare the number of log level and the one of output level set in bootstrap.php
+ *
+ * @param string $type output log level
+ * @return boolean true:output, false:not to do
+ */
function _checkLogOutputLevel($type) {
$setLevel = Configure::read('Yalog.OutputLevel');
- $setLevel = (is_null($setLevel) && is_int($setLevel)) ? LOG_DEBUG : $setLevel;
-
+
+ // Output all log when it is NULL
+ if (is_null($setLevel)) {
+ return true;
+ }
+
+ // All output log is stopped when it is false.
+ if ($setLevel === false) {
+ return false;
+ }
+
+ // Levels converted in CakeLog::write
$levels = array(
'warning' => LOG_WARNING,
'notice' => LOG_NOTICE,
@@ -91,9 +109,9 @@ function _checkLogOutputLevel($type) {
$level = $levels[$type];
} elseif (is_int($type)) {
$level = $type;
- }
-
- if (isset ($level) && $level > $setLevel) {
+ }
+
+ if (isset ($level) && ($level > $setLevel)) {
return false;
}
return true;

0 comments on commit fdc1a5c

Please sign in to comment.
Something went wrong with that request. Please try again.