X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fgabordemooij%2Fredbean%2FRedBeanPHP%2FLogger%2FRDefault.php;fp=vendor%2Fgabordemooij%2Fredbean%2FRedBeanPHP%2FLogger%2FRDefault.php;h=0a6565426372545ce153959c7a5127a4accd8013;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/vendor/gabordemooij/redbean/RedBeanPHP/Logger/RDefault.php b/vendor/gabordemooij/redbean/RedBeanPHP/Logger/RDefault.php new file mode 100755 index 000000000..0a6565426 --- /dev/null +++ b/vendor/gabordemooij/redbean/RedBeanPHP/Logger/RDefault.php @@ -0,0 +1,133 @@ +mode === self::C_LOGGER_ECHO ) { + echo $log; + } else { + $this->logs[] = $log; + } + } else { + if ( $this->mode === self::C_LOGGER_ECHO ) { + echo $argument; + } else { + $this->logs[] = $argument; + } + } + + if ( $this->mode === self::C_LOGGER_ECHO ) echo "
" . PHP_EOL; + } + } + + /** + * Returns the internal log array. + * The internal log array is where all log messages are stored. + * + * @return array + */ + public function getLogs() + { + return $this->logs; + } + + /** + * Clears the internal log array, removing all + * previously stored entries. + * + * @return self + */ + public function clear() + { + $this->logs = array(); + return $this; + } + + /** + * Selects a logging mode. + * There are several options available. + * + * * C_LOGGER_ARRAY - log silently, stores entries in internal log array only + * * C_LOGGER_ECHO - also forward log messages directly to STDOUT + * + * @param integer $mode mode of operation for logging object + * + * @return self + */ + public function setMode( $mode ) + { + if ($mode !== self::C_LOGGER_ARRAY && $mode !== self::C_LOGGER_ECHO ) { + throw new RedException( 'Invalid mode selected for logger, use C_LOGGER_ARRAY or C_LOGGER_ECHO.' ); + } + $this->mode = $mode; + return $this; + } + + /** + * Searches for all log entries in internal log array + * for $needle and returns those entries. + * This method will return an array containing all matches for your + * search query. + * + * @param string $needle phrase to look for in internal log array + * + * @return array + */ + public function grep( $needle ) + { + $found = array(); + foreach( $this->logs as $logEntry ) { + if ( strpos( $logEntry, $needle ) !== FALSE ) $found[] = $logEntry; + } + return $found; + } +}