私はphpで軽量のロギングクラスを書いています。$__LINE__
Logクラスの関数が呼び出されているファイル名/関数/行番号を自動的に記録し、ユーザーが関数を$__FILE__
呼び出すたびに入力する手間をかけずに、行番号や時間などを保存するにはどうすればよいですか 。暗黙のうちに呼べるものはありますか?
例:
class Log {
static private $instance;
static $logfile;
private function __construct(){
// doesn't need to do anything
// one logging object to avoid/control future/potential race conditions
}
public function getInstance(){
if(!Self::$instance) {
Self::$instance = new Log();
} else {
return Self::$instance;
}
}
public function criticalLog($string){
// I want this to be logging line number, filename
}
}
今、私はファイルapi.php行番号15のようなものができるようにしたいと思います
logInstance.criticalLog("This log is important");
ログファイルで見たい
12/10/09-11:15 api.php 15 This log is important
何か案は?PEARとlog4phpのソリューションを見ましたが、私が望むものにはかなり重いようです。