Ground Sunlight

Windowsで作る - PHPプログラミングの開発環境

ユーザ用ツール

サイト用ツール


apricot:usage:ja:errors-logging

差分

このページの2つのバージョン間の差分を表示します。

この比較画面にリンクする

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
最新のリビジョン 両方とも次のリビジョン
apricot:usage:ja:errors-logging [2020/09/09 08:38]
y2sunlight [デバッグ出力]
apricot:usage:ja:errors-logging [2020/09/10 18:00]
y2sunlight [アセットファイル]
行 29: 行 29:
  
 ^メソッド^機能^ ^メソッド^機能^
-|void emergency(string $message, array $context = [])|emergencyレベルのログ| +|emergency(string $message, array $context = [])|emergencyレベルのログ| 
-|void alert(string $message, array $context = [])|alertレベルのログ| +|alert(string $message, array $context = [])|alertレベルのログ| 
-|void critical(string $message, array $context = [])|criticalレベルのログ| +|critical(string $message, array $context = [])|criticalレベルのログ| 
-|void error(string $message, array $context = [])|errorレベルのログ| +|error(string $message, array $context = [])|errorレベルのログ| 
-|void warning(string $message, array $context = [])|warningレベルのログ| +|warning(string $message, array $context = [])|warningレベルのログ| 
-|void notice(string $message, array $context = [])|noticeレベルのログ| +|notice(string $message, array $context = [])|noticeレベルのログ| 
-|void info(string $message, array $context = [])|infoレベルのログ| +|info(string $message, array $context = [])|infoレベルのログ| 
-|void debug(string $message, array $context = [])|debugレベルのログ| +|debug(string $message, array $context = [])|debugレベルのログ| 
-|void log($level, string $message, array $context = [])|任意レベルのログ|+|log($level, string $message, array $context = [])|任意レベルのログ|
  
 使用例: 使用例:
行 76: 行 76:
 ===== デバッグ出力 ===== ===== デバッグ出力 =====
  
-ロギング、[[https://github.com/Seldaek/monolog|monolog]]をラップした ''Apricot\Log'' シングルトンが担当します。機能は monolog と同じですが、[[https://www.php-fig.org/psr/psr-3/|PSR-3]]に従っ使います。+Apricotではオサイトでのデバッ出力機能を実現するために、[[https://github.com/maximebf/php-debugbar|php-debugbar]]を採用しています。そして、Apricotのコアでは、php-debugbarが提供している ''\DebugBar\StandardDebugBar''スをカスタマイズした ''Apricot\Derivations\StandardDebugBar'' を作り、この機能をアプリケーション提供しています。
  
-使用法: **Log::{メソッド}**+==== DebugBarクラス ====
  
 +''DebugBar'' クラスはカスタマイズされた''StandardDebugBar''をラップしたシングルトンで、アプリケーションにデバック出力機能を提供しています。
 +
 +使用法: **DebugBar::{メソッド}**
 +
 +^メソッド^機能^
 +|renderHead():string|HTMLヘッダー用のレンダリング文字列を返す|
 +|render():mixed|HTMLボディー用のレンダリング文字列を返す|
 +|getCollector(string $name="messages"): \\ \DataCollector\DataCollectorInterface|デバッグ出力用のコレクターの取得|
 +
 +こららのメソッドの内、''renderHead()'' と ''render()'' はHTMLテンプレートで使用され、ブラウザ上にデバッグ出力をレンダリングします。また、''getCollector()'' は以下で示す [[#Debugクラス]]の生成で使用されます。
 +
 +\\
 +
 +==== Debugクラス ====
 +''Debug'' クラスは、実際にデバッグ出力を行うクラスです。機能的にはDebugBarのコレクター( DataCollectorInterface )と同じですが、ロギングと同様にPSR-3に従って以下のように使います。以下の関数は基本的に ''var_dump()'' と同じように変数の内容をダンプします (これらの関数の違いは単に出力レベルが付いているだけです)。''Debug::debug($this)'' とすれば自分のメンバ変数が全てダンプされます。
 +
 +使用法: ** Debug::{メソッド} **
 +
 +^メソッド^機能^
 +|emergency($message, array $context = [])|emergencyレベル|
 +|alert($message, array $context = [])|alertレベル|
 +|critical($message, array $context = [])|criticalレベル|
 +|error($message, array $context = [])|errorレベル|
 +|warning($message, array $context = [])|warningレベル|
 +|notice($message, array $context = [])|noticeレベル|
 +|info($message, array $context = [])|infoレベル|
 +|debug($message, array $context = [])|debugレベル|
 +|log($level, $message, array $context = [])|任意レベル|
 +
 +使用例:
 +
 +<code php>
 +use Apricot\Debug;
 +Debug::debug($this);
 +</code>
  
 \\ \\
行 106: 行 141:
 </code> </code>
  
-  * debug --- デバッグモード(既定値は 環境変数APP_DEBUG) +''debug''デバッグ出力の有効性を指するブールです。この値が真の場合、デバッグ出力が有効になります。初期設定[[apricot:usage:ja:config#環境設定|環境変数]] ''APP_DEBUG'' と同じです。 
-  * renderer.base_url --- DebugBarの公開用リソースURL + 
-  * renderer.base_path --- DebugBarの公開用リソースのサーバ内ディレクトリ +''renderer'' 要素には以下の子要素があります。 
-  * renderer.initialize --- 初期化コードをレンダリングするか否か(既定値はtrue) + 
-  * renderer.stacked_data --- スタックデータをレンダリングするか否か(既定値はtrue)+  * ''auto_assets'' --- 使用するアセットファイルの自動作成を指定します。 
 +  * ''base_url'' --- DebugBarのアセットのベースURLを指定します。 
 +  * ''base_path'' --- DebugBarのアセットのサーバ内のベースパスを指定します。 
 +  * ''initialize'' --- 初期化コードをレンダリングするか否かを指します。(デフォルト値はtrue) 
 +  * ''stacked_data'' --- スタックデータをレンダリングするか否かを指します。(デフォルト値はtrue) 
 + 
 +''auto_assets'' が true の場合、アプリケーションの初期化時に使用するリソースファイルを自動的に公開用ディレクトリーに作成します。''auto_assets'' が falseの場合は、手動でリソースファイルを作成して下さい。''base_url'' と ''base_path'' は手動の場合に指定します。 
 + 
 +''initialize''と''stacked_data''は、デバッグ出力が有効( ''<nowiki>'debug' => true</nowiki>'' )の場合に効果があり、通常は、true のままで使用して下さい。 
 + 
 +\\ 
 + 
 +==== アセットファイル ==== 
 + 
 +設定値の ''auto_assets'' がtureの場合は、アプリケーションの初期化時に自動で以下のディレクトリにのアセットファイルが作成されます。 
 + 
 +<code> 
 +/your-app-path/var/debugbar 
 +</code> 
 + 
 +''auto_assets'' がfalseの場合は、手動で以下に場所にアセットファイルを配置するように初期設定されています。 
 + 
 +<code> 
 +/your-app-path/resources/debugbar 
 +</code> 
 + 
 +デバッグ出力で使用するアセットファイルは、以下のディレクトリーに保存されているので、この下の全てのファイルとディレクリーを上記の場所にコピーして下さい。 
 + 
 +<code> 
 +/your-project/vender/maximebf/debugbar/src/DebugBar/Resources/ 
 +</code> 
 + 
 +結果的に以下のようになります: 
 + 
 +{{fa>folder-open-o}} ** /your-app-path/resources/debugbar ** 
 +<code> 
 +vendor/ 
 +widgets/ 
 +debugbar.css 
 +debugbar.js 
 +openhandler.css 
 +openhandler.js 
 +widgets.css 
 +widgets.js 
 +</code>
  
 \\ \\
apricot/usage/ja/errors-logging.txt · 最終更新: 2020/09/10 18:02 by y2sunlight