reset(); return $GLOBALS['bxDolClasses'][__CLASS__]; } /** * Reset custom log file and log name * to be empty to ready for future usage. */ public function reset() { $this->_sFile = ''; $this->_sName = ''; } /** * Set custom log file. The file should have necessary permissions. * @param string $sFile - full path to custom log file. */ public function setFile($sFile) { $this->_sFile = $sFile; } /** * Set log name. Log file will be created\updated in standard log directory. * @param string $sName - log file name without path and extension. */ public function setName($sName) { $this->_sName = $sName; } /** * Writes content to a log file. Can get any number of arguments to be written * in one write session. Each argument can be a string, an array or an object. */ public function write() { if(func_num_args() == 0) return; try { $sFile = ''; if(!empty($this->_sFile)) $sFile = $this->_sFile; else $sFile = BX_DIRECTORY_PATH_LOGS . '/' . $this->_sName . '.log'; if(empty($sFile)) return; file_put_contents($sFile, date('m-d H:i:s') . ":\n", FILE_APPEND); $aArgs = func_get_args(); foreach($aArgs as $mixedArg) { if(is_array($mixedArg)) $mixedArg = var_export($mixedArg, true); else if(is_object($mixedArg)) $mixedArg = json_encode($mixedArg); file_put_contents($sFile, $mixedArg . "\n", FILE_APPEND); } } catch (Exception $oException) { echo 'Error: ' . $oException->getMessage(); } } } /** @} */