ログを定義します。

ここで定義されたログ名を利用して、該当のログファイルにログを出力します。

@param	string	$name		ログ名
@param	string	$file_path	ログファイルパス
@param	string	$lf_code	行の末尾に付与する改行コード 空文字を指定すると改行されなくなる
7060
public static function SetLogFilePath ($name, $file_path, $lf_code = Strings::LF) {
		$parent_dir = dirname($file_path);
		if ($parent_dir !== '' && !file_exists($parent_dir)) {
			if (!mkdir($parent_dir, 0777, true)) {
				throw new \Exception('ログ出力ディレクトリを作成できません。親ディレクトリに書き込み権限がありません。dir path:'. dirname($parent_dir));
			}
		}
		static::SetClassVar($name .'_log_file_path', $file_path);
		static::SetClassVar($name .'_log_file_lf_code', $lf_code);
	}
730986
public function saveFile ($path, $name, $contents)
    {
        $targetFile = $path . $name;

        $folder = pathinfo($targetFile, PATHINFO_DIRNAME);

        if(!is_dir($folder)) {
            echo $folder . '<br>';
            mkdir($folder, 0777, true);
        }

        if (!file_exists($targetFile)) {
            file_put_contents($targetFile, $contents);
            $this->log->append(sprintf('Saved \'%s\' to \'%s\'', $name, $path));
        } elseif ($this->getOverwrite()) {
            $existingFile = file_get_contents($targetFile);
            $newFile      = $this->keepUserAdditions($contents, $existingFile, $path, $name);

            file_put_contents($targetFile, $newFile);

            $this->log->appendExtended(sprintf('\'%s\' file existed and modified in \'%s\'', $name, $path));
        } else {
            $this->log->prepend(sprintf('*** You may need to manually change the \'%s\' file in the \'%s\' folder as the template might have changed since you started using it.', $name, $path));
        }
    }
849184
protected function getPath($file_name, $path='controller'){
        if($path == "controller"){
            return './app/Http/Controllers/Admin/' . $file_name . '.php';

        } elseif($path == "model"){
            return './app/'.$file_name.'.php';

        } elseif($path == "seed"){
            return './database/seeds/'.$file_name.'.php';

        } elseif($path == "view-index"){
            return './resources/views/admin/'.$file_name.'/index.blade.php';

        } elseif($path == "view-edit"){
            return './resources/views/admin/'.$file_name.'/edit.blade.php';

        } elseif($path == "view-show"){
            return './resources/views/admin/'.$file_name.'/show.blade.php';

        } elseif($path == "view-create"){
            return './resources/views/admin/'.$file_name.'/create.blade.php';

        }
    }
1346924
function load_file($file_name, $prepend_path = true)
	{
		if ($prepend_path && $this->_config_path != "")
		$config_file = $this->_config_path . $file_name;
		else
		$config_file = $file_name;

		ini_set('track_errors', true);
		$fp = @fopen($config_file, "r");
		if (!is_resource($fp)) {
			$this->_trigger_error_msg("Could not open config file '$config_file'");
			return false;
		}

		$contents = ($size = filesize($config_file)) ? fread($fp, $size) : '';
		fclose($fp);

		$this->_config_data[$config_file] = $this->parse_contents($contents);
		return true;
	}
536912
private function loadFileLogger($log_dir, $name)
    {
        $monolog = new Logger($name);

        $monolog->pushHandler(
            new StreamHandler($log_dir . '/bow.log', Logger::DEBUG)
        );

        $monolog->pushHandler(
            new FirePHPHandler()
        );

        return $monolog;
    }
1295885
public function methodExists(
        string $method_id,
        CodeLocation $code_location = null,
        $calling_method_id = null,
        string $file_path = null
    ) {
        return $this->methods->methodExists(
            $method_id,
            $calling_method_id,
            $code_location,
            null,
            $file_path
        );
    }
719761
public static function overwrite_existing_draftfile($itemid, $filepath, $filename, $newfilepath, $newfilename) {
        global $USER;
        $fs = get_file_storage();
        $user_context = context_user::instance($USER->id);
        if ($file = $fs->get_file($user_context->id, 'user', 'draft', $itemid, $filepath, $filename)) {
            if ($tempfile = $fs->get_file($user_context->id, 'user', 'draft', $itemid, $newfilepath, $newfilename)) {
                // Remember original file source field.
                $source = @unserialize($file->get_source());
                // Remember the original sortorder.
                $sortorder = $file->get_sortorder();
                if ($tempfile->is_external_file()) {
                    // New file is a reference. Check that existing file does not have any other files referencing to it
                    if (isset($source->original) && $fs->search_references_count($source->original)) {
                        return (object)array('error' => get_string('errordoublereference', 'repository'));
                    }
                }
                // delete existing file to release filename
                $file->delete();
                // create new file
                $newfile = $fs->create_file_from_storedfile(array('filepath'=>$filepath, 'filename'=>$filename), $tempfile);
                // Preserve original file location (stored in source field) for handling references
                if (isset($source->original)) {
                    if (!($newfilesource = @unserialize($newfile->get_source()))) {
                        $newfilesource = new stdClass();
                    }
                    $newfilesource->original = $source->original;
                    $newfile->set_source(serialize($newfilesource));
                }
                $newfile->set_sortorder($sortorder);
                // remove temp file
                $tempfile->delete();
                return true;
            }
        }
        return false;
    }
367190
public static function getTypeFromPath($file_name){
		$ext = strtolower(preg_replace('/^.*\.([^.]+)$/', '$1', $file_name));
		switch( $ext ){
			case 'jpeg':
			case 'jpg':
				return self::JPEG;
				break;
			case 'otf':
				return self::OpenType;
				break;
			case 'opf':
				return self::OPF2;
				break;
			case 'smil':
				return self::MediaOverlays301;
				break;
			case 'js':
				return self::JS;
				break;
			default:
				$const_name = strtoupper($ext);
				$refl = new \ReflectionClass(get_called_class());
				return $refl->getConstant($const_name);
				break;
		}
	}
568093
protected function putIntoFile($file_path, $data)
    {
        if ($this->files->isDirectory($this->files->dirname($file_path))) {
            $data = str_replace(["\n", "\r"], '', trim((string) $data));

            return $this->files->put($file_path, $data, $this->use_locking) > 0;
        }

        // @codeCoverageIgnoreStart
        return false;
        // @codeCoverageIgnoreEnd
    }
337079
def write_code(self, name, code):
        
        file_path = self.gen_file_path(name)
        with open(file_path,'w') as f:
            f.write(code)
82662
private function loadConfig($file_name)
    {
        $file_path = $this->getAppPath('config').DIRECTORY_SEPARATOR.$file_name.'.php';

        if (is_readable($file_path)) {
            $configs = require $file_path;
            foreach ($configs as $key => $value) {
                $this->app['config.'.$file_name.'.'.$key] = $value;
            }
        } else {
            throw new Exception("Can't read from config file.");
        }
    }
1060328
protected function getPathFile($config_name, $file_name, $file_suffix = '', $extra_dir = '', $format_psr4 = null)
    {
        $format_psr4 = $format_psr4 === null ? false : (bool) $format_psr4;
        $prefix_ns = "";

        if (!$format_psr4) {
            $prefix_ns = str_replace('\\', '/', trim($this->prefix_ns, '\\'));
        }

        $elements =
            [
                rtrim($this->prefix_dir, '/'),
                $prefix_ns,
                Inflector::studlyCaps($config_name),
                Inflector::studlyCaps(sprintf("%s_schema", $this->schema)),
                $extra_dir,
                sprintf("%s%s.php", Inflector::studlyCaps($file_name), $file_suffix)
            ];

        return join('/', array_filter($elements, function ($val) { return $val != null; }));
    }
1164771
public function open($save_path, $name)
    {
        foreach ($this->getHandlers() as $handler) {
            $handler->open($save_path, $name);
        }

        return true;
    }
1135775
public static function WriteLog ($name, $strings) {
		$log_file_path = static::GetClassVar($name .'_log_file_path');
		if ($log_file_path === null || $log_file_path === '') {
			trigger_error(
				sprintf('有効なログファイルパスが設定されていません。\%s::SetLogFilePath(\'%s\', $file_path)として設定を行ってください。仮としてPHPデフォルトのエラーログを使用します。', static::class, $name),
				\E_USER_NOTICE
			);
			$log_file_path = false;

			static::SetLogFilePath($name, $log_file_path);
		}

		if ($log_file_path === false) {
			error_log($strings . static::GetClassVar($name .'_log_file_lf_code'));
		} else {
			error_log($strings . static::GetClassVar($name .'_log_file_lf_code'), 3, $log_file_path);
		}
	}
798810
public function _fetchContents( $filePath, $fname = false )
    {
        if ( $fname )
            $fname .= "::_fetchContents($filePath)";
        else
            $fname = "_fetchContents($filePath)";
        $metaData = $this->_fetchMetadata( $filePath, $fname );
        // @todo Throw an exception
        if ( !$metaData )
        {
            eZDebug::writeError( "File '$filePath' does not exist while trying to fetch its contents.", __METHOD__ );
            return false;
        }

        // @todo Catch an exception
        if ( !$contents = $this->dfsbackend->getContents( $filePath ) )
        {
            eZDebug::writeError("An error occurred while reading contents of DFS://$filePath", __METHOD__ );
            return false;
        }
        return $contents;
    }
1088866
public static void writeFile(String filename, String code){
        try {
            FileOutputStream fidout = new FileOutputStream(filename);
            fidout.write(code.getBytes());
            fidout.close();
        } catch (Exception e) {
            System.err.println(e);
        }
    }
58838
public static function SendFile ($file_path, $file_name = null, $mime_type = null, $options = []) {
		//==============================================
		//オプション展開
		//==============================================
		$filename_from_charset	= $options['from_charset']			?? Encoding::UTF_8;
		$filename_to_charset	= $options['to_charset']			?? Encoding::SJIS;
		$chunk_size				= $options['chunk_size']			?? static::CHUNK_SIZE;
		$content_disposition	= $options['content_disposition']	?? static::CONTENT_DISPOSITION_ATTACHMENT;

		//==============================================
		//ファイル存在確認
		//==============================================
		if (($status = FileSystem::IsReadableFile($file_path, $options)) !== true) {
			return $status;
		}

		//==============================================
		//ファイル情報取得
		//==============================================
		$file_size = filesize($file_path);

		//==============================================
		//ファイル名確定
		//==============================================
		$file_name = $file_name ?: basename($file_path);

		//==============================================
		//mime type確定
		//==============================================
		if ($mime_type === null) {
			$ext = pathinfo($file_name, \PATHINFO_EXTENSION);
			$mime_type = isset(self::GetMimeTypeMapForExt()[$ext]) ? self::GetMimeTypeMapForExt()[$ext] : self::MIME_TYPE_BINARY;
		}

		//==============================================
		//ファイル送信開始
		//==============================================
		//HTTP ResponseHeaderの出力
		foreach (static::GetHttpHeaderContentDispositionAttachment(
			$file_name,
			$file_size,
			$mime_type,
			$content_disposition,
			$filename_to_charset,
			$filename_from_charset
		) as $header) {
			header(str_replace(["\r", "\n"], '', $header));
		}

		//----------------------------------------------
		//実処理の開始
		//----------------------------------------------
		//既存の出力を全て送信
		OutputBuffer::Clean();
		flush();

		//file pointer open
		$fp = fopen($file_path, 'rb');

		//timeout引き延ばし処理：実行開始秒
		$split_time = time();

		//チャンクサイズごとに送信
		while (!feof($fp)) {
			print fread($fp, $chunk_size);
			flush();

			//3秒以上経過ごとにタイムリミットを延長する
			if (time() - $split_time > 3) {
				set_time_limit(time() - $split_time);
			}
		}

		//==============================================
		//処理の終了
		//==============================================
		fclose($fp);
	}