Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
add clientId to record
Browse files Browse the repository at this point in the history
  • Loading branch information
fvovan committed Dec 16, 2015
1 parent 1303613 commit b38b6c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions library/CM/Log/Handler/MongoDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ protected function _formatRecord(CM_Log_Record $record) {
'server' => $request->getServer(),
'headers' => $request->getHeaders(),
];

if ($request->hasClientId()) {
$formattedContext['httpRequest']['clientId'] = $request->getClientId();
}
}

return [
Expand Down
2 changes: 2 additions & 0 deletions tests/library/CM/Log/Handler/MongoDbTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function testWriting() {
$ttl = 30;
$user = CMTest_TH::createUser();
$httpRequest = CM_Http_Request_Abstract::factory('post', '/foo?bar=1&baz=quux', ['bar' => 'baz'], ['foo' => 'quux'], '{"bar":"2", "quux":"baz"}');
$clientId = $httpRequest->getClientId();
$computerInfo = new CM_Log_Context_ComputerInfo('www.example.com', 'v7.0.1');

$mongoClient = $this->getServiceManager()->getMongoDb();
Expand Down Expand Up @@ -68,6 +69,7 @@ public function testWriting() {
$this->assertSame(['bar' => '2', 'baz' => 'quux', 'quux' => 'baz'], $context['httpRequest']['query']);
$this->assertSame(['bar' => 'baz'], $context['httpRequest']['headers']);
$this->assertSame(['foo' => 'quux'], $context['httpRequest']['server']);
$this->assertSame($clientId, $context['httpRequest']['clientId']);
$this->assertSame('www.example.com', $context['computerInfo']['fqdn']);
$this->assertSame('v7.0.1', $context['computerInfo']['phpVersion']);
$this->assertSame(['bar' => ['baz' => 'quux']], $context['extra']);
Expand Down

0 comments on commit b38b6c6

Please sign in to comment.