diff --git a/src/Guzzle/Common/Log/ArrayLogAdapter.php b/src/Guzzle/Common/Log/ArrayLogAdapter.php new file mode 100644 index 00000000..0c5b3e79 --- /dev/null +++ b/src/Guzzle/Common/Log/ArrayLogAdapter.php @@ -0,0 +1,41 @@ +logs[] = array('message' => $message, 'priority' => $priority, 'extras' => $extras); + } + + /** + * Get logged entries + * + * @return array + */ + public function getLogs() + { + return $this->logs; + } + + /** + * Clears logged entries + */ + public function clearLogs() + { + $this->logs = array(); + } +} diff --git a/tests/Guzzle/Tests/Common/Log/ArrayLogAdapterTest.php b/tests/Guzzle/Tests/Common/Log/ArrayLogAdapterTest.php new file mode 100644 index 00000000..59b1de61 --- /dev/null +++ b/tests/Guzzle/Tests/Common/Log/ArrayLogAdapterTest.php @@ -0,0 +1,26 @@ +log('test', \LOG_NOTICE, 'localhost'); + $this->assertEquals(array(array('message' => 'test', 'priority' => \LOG_NOTICE, 'extras' => 'localhost')), $adapter->getLogs()); + } + + public function testClearLog() + { + $adapter = new ArrayLogAdapter(); + + $adapter->log('test', \LOG_NOTICE, 'localhost'); + $adapter->clearLogs(); + $this->assertEquals(array(), $adapter->getLogs()); + } +}