Skip to content

Commit 13d2468

Browse files
committed
admin/log/entries
1 parent a570f9b commit 13d2468

File tree

5 files changed

+89
-16
lines changed

5 files changed

+89
-16
lines changed

CHANGELOG.md

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,27 @@
22

33
## Release notes for the ArangoDB-PHP driver 3.8.x
44

5+
The driver now supports the following options for document CRUD operations:
6+
- "overwriteMode"
7+
- "silent"
8+
- "keepNull", "mergeObjects" (for insert API if overwriteMode=update)
9+
10+
Extended maximum valid length for collection names to 256, up from 64 before. This follows a
11+
change in the ArangoDB server.
12+
13+
Indexes can now be created with "deduplicate" and "estimates" attribute set/not set.
14+
15+
The engine stats API is now supported via `AdminHandler::getEngineStats()`.
16+
17+
The metrics API is now supported via `AdminHandler::getMetrics()`.
18+
19+
Collection objects now support schemas via the `getSchema()`, `setSchema()` methods.
20+
21+
The `Cursor` class will now fetch outstanding cursor result data via HTTP POST requests to
22+
`/_api/cursor/<cursor-id>`. It previously fetched further results via HTTP PUT requests from
23+
the same address. The change is necessary because fetching further results is not an
24+
idempotent operation, but the HTTP standard requires PUT operations to be idempotent.
25+
526
In this version of the PHP driver the following classes are deprecated, because their
627
corresponding server-side APIs have been deprecated in ArangoDB 3.8:
728

@@ -13,19 +34,8 @@ In addition, the following functionality is deprecated:
1334

1435
- CollectionHandler::load()
1536
- CollectionHandler::unload()
16-
17-
The `Cursor` class will now fetch outstanding cursor result data via HTTP POST requests to
18-
`/_api/cursor/<cursor-id>`. It previously fetched further results via HTTP PUT requests from
19-
the same address. The change is necessary because fetching further results is not an
20-
idempotent operation, but the HTTP standard requires PUT operations to be idempotent.
21-
22-
Extended maximum valid length for collection names to 256, up from 64 before. This follows a
23-
change in the ArangoDB server.
24-
25-
The driver now supports the following options for document CRUD operations:
26-
- "overwriteMode"
27-
- "silent"
28-
- "keepNull", "mergeObjects" (for insert API if overwriteMode=update)
37+
- AdminHandler::getServerStatistics()
38+
- AdminHandler::getServerStatisticsDescription()
2939

3040
The following options have been removed in class Collection:
3141
- isVolatile

lib/ArangoDBClient/AdminHandler.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,44 @@ public function getServerTime()
127127

128128
return $data['time'];
129129
}
130+
131+
132+
/**
133+
* Get the server log entries
134+
*
135+
* This will throw if the log cannot be retrieved
136+
*
137+
* @throws Exception
138+
*
139+
* @param array $options - an array of options that define the result-set:
140+
*
141+
* <p>Options are :<br>
142+
* <li>'upto' - returns all log entries up to a log-level. Note that log-level must be one of:</li>
143+
* <p>
144+
* <li>fatal / 0</li>
145+
* <li>error / 1</li>
146+
* <li>warning / 2</li>
147+
* <li>info / 3</li>
148+
* <li>debug / 4</li>
149+
* </p>
150+
* <li>'level' - limits the log entries to the ones defined in level. Note that `level` and `upto` are mutably exclusive.</li>
151+
* <li>'offset' - skip the first offset entries.</li>
152+
* <li>'size' - limit the number of returned log-entries to size.</li>
153+
* <li>'start' - Returns all log entries such that their log-entry identifier is greater or equal to lid.</li>
154+
* <li>'sort' - Sort the log-entries either ascending if direction is asc, or descending if it is desc according to their lid. Note that the lid imposes a chronological order.</li>
155+
* <li>'search' - Only return the log-entries containing the text string...</li>
156+
* </p>
157+
*
158+
* @return array - an array holding the various attributes of a log: lid, level, timestamp, text and the total amount of log entries before pagination.
159+
* @since 1.2
160+
*/
161+
public function getServerLogEntries(array $options = [])
162+
{
163+
$url = UrlHelper::appendParamsUrl(Urls::URL_ADMIN_LOG_ENTRIES, $options);
164+
$response = $this->getConnection()->get($url);
165+
166+
return $response->getJson();
167+
}
130168

131169

132170
/**
@@ -154,6 +192,7 @@ public function getServerTime()
154192
* <li>'sort' - Sort the log-entries either ascending if direction is asc, or descending if it is desc according to their lid. Note that the lid imposes a chronological order.</li>
155193
* <li>'search' - Only return the log-entries containing the text string...</li>
156194
* </p>
195+
* @deprecated use getServerLogEntries() instead
157196
*
158197
* @return array - an array holding the various attributes of a log: lid, level, timestamp, text and the total amount of log entries before pagination.
159198
* @since 1.2

lib/ArangoDBClient/Collection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ public function setWriteConcern($value)
834834
*
835835
* @param int $value - write concern value
836836
*
837-
* @deprecated use setWriteConcern instead
837+
* @deprecated use setWriteConcern() instead
838838
* @return void
839839
*/
840840
public function setMinReplicationFactor($value)
@@ -855,7 +855,7 @@ public function getWriteConcern()
855855
/**
856856
* Get the write concern value (if already known). this is an alias only
857857
*
858-
* @deprecated use getWriteConcern instead
858+
* @deprecated use getWriteConcern() instead
859859
* @return mixed - write concern value
860860
*/
861861
public function getMinReplicationFactor()

lib/ArangoDBClient/Urls.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,14 @@ abstract class Urls
199199
const URL_ADMIN_TIME = '/_admin/time';
200200

201201
/**
202-
* URL for admin log
202+
* URL for admin log (deprecated)
203203
*/
204204
const URL_ADMIN_LOG = '/_admin/log';
205+
206+
/**
207+
* URL for admin log entries
208+
*/
209+
const URL_ADMIN_LOG_ENTRIES = '/_admin/log/entries';
205210

206211
/**
207212
* base URL part for admin routing reload (deprecated)

tests/AdminTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,25 @@ public function testGetServerTime()
8787
$result = $this->adminHandler->getServerTime();
8888
static::assertTrue(is_float($result), 'Time must be a double (float)!');
8989
}
90+
91+
92+
/**
93+
* Test if we can get the server log
94+
* Rather dumb tests just checking that an array is returned
95+
*/
96+
public function testGetServerLogEntries()
97+
{
98+
$result = $this->adminHandler->getServerLogEntries();
99+
static::assertTrue(is_array($result), 'Should be an array');
100+
101+
foreach ($result as $entry) {
102+
static::assertArrayHasKey('id', $entry);
103+
static::assertArrayHasKey('topc', $entry);
104+
static::assertArrayHasKey('level', $entry);
105+
static::assertArrayHasKey('date', $entry);
106+
static::assertArrayHasKey('message', $entry);
107+
}
108+
}
90109

91110

92111
/**

0 commit comments

Comments
 (0)