init(); } return Logger::$instance; } function __construct() { // calculate user specific file name $user = getenv("USER"); $fileName = "/tmp/{$user}data.log"; $this->fp = fopen($fileName, 'a'); if ( !$this->fp ){ throw new Exception("cannot open log file"); } } function log( $comp, $string ) { fwrite($this->fp, "$comp : $string\n"); } function logException( $comp, Exception $e ) { $this->log( $comp, $e->getMessage() ); $this->log( $comp, $e->getTraceAsString() ); } } ?>