Recently in Firebug Category

PEARのLogパッケージを使用して、Firebugにログを出力する方法を次に示す。
元ネタは「cl.pocari.org - PEAR Log を使って Firebug にログを出力する」。

まず、Logパッケージをインストールする。

# pear install Log
WARNING: "pear/DB" is deprecated in favor of "pear/MDB2"
Did not download optional dependencies: pear/DB, pear/MDB2, use --alldeps to download automatically
pear/Log can optionally use package "pear/DB" (version >= 1.3)
pear/Log can optionally use package "pear/MDB2" (version >= 2.0.0RC1)
pear/Log can optionally use PHP extension "sqlite"
downloading Log-1.9.11.tgz ...
Starting to download Log-1.9.11.tgz (38,479 bytes)
..........done: 38,479 bytes
install ok: channel://pear.php.net/Log-1.9.11

あとはLogクラスのインスタンスを生成し、logメソッドを呼ぶだけ。
具体的なコードは次の通り。

<?php
require_once 'Log.php';

$log = &Log::singleton('firebug', '', 'PHP', array('buffering' => true), PEAR_LOG_DEBUG);

$log->log('デバッグレベル', PEAR_LOG_DEBUG);
$log->log('情報レベル', PEAR_LOG_INFO);$log->log('警告レベル', PEAR_LOG_WARNING);
$log->log('エラーレベル', PEAR_LOG_ERR);
$log->log('レベル??');
?>

これで、次のようにFirebugのエラーコンソールにメッセージが出力される。

php_firebug.png

Enjoy!

About this Archive

This page is a archive of recent entries in the Firebug category.

読書 is the previous category.

JavaScript is the next category.

Find recent content on the main index or look in the archives to find all content.