get_site_root(); $site_root = Factory::getFilesystemTools()->TranslateWinPath( $site_root_untranslated ); } if(empty($configuredLoglevel) or ($level === true)) { // Load the registry and fetch log level $registry = Factory::getConfiguration(); $configuredLoglevel = $registry->get('akeeba.basic.log_level'); $configuredLoglevel = $configuredLoglevel * 1; return; } if($level === false) { // Pause logging $configuredLogLevel = false; return; } // Catch paused logging if($configuredLoglevel === false) return; if( ($configuredLoglevel >= $level) && ($configuredLoglevel != 0)) { if(!defined('AKEEBADEBUG')) { $message = str_replace( $site_root_untranslated, "", $message ); $message = str_replace( $site_root, "", $message ); } $message = str_replace( "\n", ' \n ', $message ); switch( $level ) { case _AE_LOG_ERROR: $string = "ERROR |"; break; case _AE_LOG_WARNING: $string = "WARNING |"; break; case _AE_LOG_INFO: $string = "INFO |"; break; default: $string = "DEBUG |"; break; } $string .= @strftime( "%y%m%d %H:%M:%S" ) . "|$message\r\n"; if(is_null($fp)) { $fp = @fopen( AliceUtilLogger::$logName, "a" ); } if (!($fp === FALSE)) { $result = @fwrite( $fp, $string ); if($result === false) { // Try harder with the file pointer, will ya? $fp = @fopen( AliceUtilLogger::$logName, "a" ); $result = @fwrite( $fp, $string ); } } } } /** * Calculates the absolute path to the log file. Instead of using the path coming from * Akeeba Backup config, we will always use the Tmp dir * * @param string $tag The backup run's tag * * @return string The absolute path to the log file */ public static function logName( $tag = null) { if(empty($tag)) { $fileName = 'akeeba.log'; } else { $fileName = "akeeba.$tag.log"; } // Get log's file name return Factory::getFilesystemTools()->TranslateWinPath(APATH_ROOT.'/tmp'.DIRECTORY_SEPARATOR.$fileName); } public static function closeLog() { self::WriteLog(null,null); } public static function openLog($tag = null) { self::$logName = self::logName($tag); @touch(self::$logName); } } // Make sure we close the log file every time we finish with a page load register_shutdown_function( array('AliceUtilLogger','closeLog') );