Logger::openLogFile PHP Method

openLogFile() public method

public openLogFile ( $severity = 'error' )
    public function openLogFile($severity = 'error')
    {
        if (!is_dir($this->log_dir)) {
            // Directory is not writable, let's first try to create it
            if (!mkdir($this->log_dir, 0750)) {
                throw new BaseException("Unable to create {$this->log_dir} for log output");
            }
        }
        $filename = 'am3_' . $severity . '_log';
        $full_filename = $this->log_dir . DIRECTORY_SEPARATOR . $filename;
        if (!is_writable($full_filename) && !is_writable($this->log_dir)) {
            throw new BaseException("Log file is not writable and seems I won't be able to create it: {$full_filename}");
        }
        if (is_link($full_filename)) {
            throw new BaseException('Log file is a symlink. Are you trying to make me overwrite somethingn?');
        }
        ini_set($severity . '_log', $full_filename);
        //$full_filename=tempnam($this->log_dir,$filename);
        $new_file = file_exists($full_filename) ? false : true;
        $log_file = "log_{$severity}" . '_file';
        $this->{$log_file} = fopen($full_filename, 'a');
        if (!$this->{$log_file}) {
            throw new BaseException("Cannot open {$severity} log file");
        }
        if ($new_file) {
            chmod($full_filename, 0777);
        }
        //
    }