* @license LGPL http://www.gnu.org/licenses/lgpl.html * @package wb * @subpackage Log */ /** * Basic log driver * * @version 0.1.1 * @package wb * @subpackage Factory * @example test/example/wb.php * @test test/unit/log */ class WBLog_File extends WBLog { /** * logfile to be used * @var string */ private $_logFile = null; /** * constructor * * @param string $service */ protected function __construct( $service, $config ) { parent::__construct( $service, $config ); // where to log to? $file = $this->_service; if( isset( $this->_config['file'] ) ) { $file = $this->_config['file']; } $base = WBParam::get( 'wb/dir/base' ); $this->_logFile = sprintf( '%s/var/log/%s.log', $base, $file ); // touch file if( !file_exists( $this->_logFile ) ) { touch( $this->_logFile ); chmod( $this->_logFile, 0666 ); } } /** * Write log message * * @param int $level * @param mixed $msg * @return true on success */ protected function write( $level, $msg ) { $str = array( gmdate( parent::$_dateFormat ), $this->_host, $this->_service, $this->_session, $level, $msg ); error_log( implode( ' ', $str ) . "\n", 3, $this->_logFile ); return true; } } ?>