|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00027 require_once 'Zend/Http/Client/Adapter/Socket.php'; 00028 00041 class Zend_Gdata_App_LoggingHttpClientAdapterSocket extends Zend_Http_Client_Adapter_Socket 00042 { 00043 00049 protected $log_handle = null; 00050 00058 protected function log($message) 00059 { 00060 if ($this->log_handle == null) { 00061 $this->log_handle = fopen($this->config['logfile'], 'a'); 00062 } 00063 fwrite($this->log_handle, $message); 00064 } 00065 00074 public function connect($host, $port = 80, $secure = false) 00075 { 00076 $this->log("Connecting to: ${host}:${port}"); 00077 return parent::connect($host, $port, $secure); 00078 } 00079 00090 public function write($method, $uri, $http_ver = '1.1', $headers = array(), $body = '') 00091 { 00092 $request = parent::write($method, $uri, $http_ver, $headers, $body); 00093 $this->log("\n\n" . $request); 00094 return $request; 00095 } 00096 00102 public function read() 00103 { 00104 $response = parent::read(); 00105 $this->log("${response}\n\n"); 00106 return $response; 00107 } 00108 00113 public function close() 00114 { 00115 $this->log("Closing socket\n\n"); 00116 parent::close(); 00117 } 00118 00119 }