* @version 0.1.2
*/
+use Psr\Log\LoggerInterface;
+use Psr\Log\NullLogger;
+
// {{{ requirements
// }}}
*/
public $_connect_attempts;
+ /**
+ * @var LoggerInterface
+ */
+ private $_logger;
+
// }}}
// }}}
// {{{ methods
$this->_connect_timeout = isset( $args['connect_timeout'] ) ? $args['connect_timeout'] : 0.1;
$this->_connect_attempts = 2;
+
+ $this->_logger = isset( $args['logger'] ) ? $args['logger'] : new NullLogger();
}
// }}}
* @return mixed
*/
public function get( $key, &$casToken = null ) {
- wfProfileIn( __METHOD__ );
if ( $this->_debug ) {
$this->_debugprint( "get($key)\n" );
if ( !is_array( $key ) && strval( $key ) === '' ) {
$this->_debugprint( "Skipping key which equals to an empty string" );
- wfProfileOut( __METHOD__ );
return false;
}
if ( !$this->_active ) {
- wfProfileOut( __METHOD__ );
return false;
}
$sock = $this->get_sock( $key );
if ( !is_resource( $sock ) ) {
- wfProfileOut( __METHOD__ );
return false;
}
$cmd = "gets $key\r\n";
if ( !$this->_fwrite( $sock, $cmd ) ) {
- wfProfileOut( __METHOD__ );
return false;
}
if ( isset( $val[$key] ) ) {
$value = $val[$key];
}
- wfProfileOut( __METHOD__ );
return $value;
}
* @param string $text
*/
function _debugprint( $text ) {
- wfDebugLog( 'memcached', $text );
+ $this->_logger->debug( $text );
}
/**
* @param string $text
*/
function _error_log( $text ) {
- wfDebugLog( 'memcached-serious', "Memcached error: $text" );
+ $this->_logger->error( "Memcached error: $text" );
}
/**