/** * log method * * Record to the log (the head doc block on first load in debug mode) or output the log (call with no params) * * @param mixed $string * @static * @return logs contents if requested, otherwise null * @access public */ public static function log($string = null, $shellObject = null) { if (self::$start === null) { self::$start = microtime(true); } static $log = array(); if ($shellObject) { self::$__Shell =& $shellObject; } if ($string === null) { $settings = self::$settings; ksort($settings); foreach ($settings as $k => &$v) { $v = ' ' . str_pad($k, 15, ' ', STR_PAD_RIGHT) . "\t: " . $v; } $settings[] = ''; $head = array_merge(array('MiCompressor log - (only generated on first load) ' . date("D, M jS Y, H:i:s"), null), $settings); $log = array_merge($head, $log); $return = "/**\r\n * " . implode("\r\n * ", $log) . "\r\n */\r\n"; $log = array(); self::$start = microtime(true); return $return; } if (strpos($string, 'PROBLEM') !== false && class_exists('Object')) { $Object = new Object(); $Object->log($string, 'mi_compressor'); } $time = microtime(true) - self::$start; $msg = str_pad(number_format($time, 3, '.', ''), 6, ' ', STR_PAD_LEFT) . 's ' . $string; if (!empty(self::$__Shell)) { self::$__Shell->out($msg); } $log[] = $msg; }