/** * Logging * * @param string $msg * @param string $funcName * @param string $preFix * @param UDate $start * @param string $postFix * * @return UDate */ private static function _log($msg, $funcName = '', $preFix = "", UDate $start = null, $postFix = "\r\n") { $now = new UDate(); $timeElapsed = ''; if ($start instanceof UDate) { $timeElapsed = $now->diff($start); $timeElapsed = ' TOOK (' . $timeElapsed->format('%s') . ') seconds '; } $nowString = ''; if (trim($msg) !== '') { $nowString = ' [' . trim($now) . '] '; } $logMsg = $preFix . $msg . $nowString . $timeElapsed . ($funcName !== '' ? ' ' . $funcName . ' ' : '') . $postFix; echo $logMsg; if (is_file(self::$_logFile)) { file_put_contents(self::$_logFile, $logMsg, FILE_APPEND); } return $now; }