Skip to content

Commit d225c3c

Browse files
author
Mark
committed
added ArangoDBAsync.getLogLevel() / setLogLevel()
1 parent e35ef56 commit d225c3c

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

src/main/java/com/arangodb/ArangoDBAsync.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
import com.arangodb.entity.ArangoDBVersion;
3232
import com.arangodb.entity.LogEntity;
33+
import com.arangodb.entity.LogLevelEntity;
3334
import com.arangodb.entity.UserEntity;
3435
import com.arangodb.internal.ArangoDBConstants;
3536
import com.arangodb.internal.ArangoExecutorAsync;
@@ -411,4 +412,25 @@ public CompletableFuture<LogEntity> getLogs(final LogOptions options) {
411412
return executor.execute(getLogsRequest(options), LogEntity.class);
412413
}
413414

415+
/**
416+
* Returns the server's current loglevel settings.
417+
*
418+
* @return the server's current loglevel settings
419+
* @throws ArangoDBException
420+
*/
421+
public CompletableFuture<LogLevelEntity> getLogLevel() {
422+
return executor.execute(getLogLevelRequest(), LogLevelEntity.class);
423+
}
424+
425+
/**
426+
* Modifies and returns the server's current loglevel settings.
427+
*
428+
* @param entity
429+
* loglevel settings
430+
* @return the server's current loglevel settings
431+
* @throws ArangoDBException
432+
*/
433+
public CompletableFuture<LogLevelEntity> setLogLevel(final LogLevelEntity entity) {
434+
return executor.execute(setLogLevelRequest(entity), LogLevelEntity.class);
435+
}
414436
}

src/test/java/com/arangodb/ArangoDBTest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import com.arangodb.entity.ArangoDBVersion;
4444
import com.arangodb.entity.LogEntity;
4545
import com.arangodb.entity.LogLevel;
46+
import com.arangodb.entity.LogLevelEntity;
4647
import com.arangodb.entity.UserEntity;
4748
import com.arangodb.model.LogOptions;
4849
import com.arangodb.model.LogOptions.SortOrder;
@@ -468,4 +469,34 @@ public void getLogsSortDesc() throws InterruptedException, ExecutionException {
468469
f.get();
469470
}
470471

472+
@Test
473+
public void getLogLevel() throws InterruptedException, ExecutionException {
474+
final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build();
475+
final CompletableFuture<LogLevelEntity> f = arangoDB.getLogLevel();
476+
assertThat(f, is(notNullValue()));
477+
f.whenComplete((logLevel, ex) -> {
478+
assertThat(logLevel, is(notNullValue()));
479+
assertThat(logLevel.getAgency(), is(LogLevelEntity.LogLevel.INFO));
480+
});
481+
f.get();
482+
}
483+
484+
@Test
485+
public void setLogLevel() throws InterruptedException, ExecutionException {
486+
final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build();
487+
final LogLevelEntity entity = new LogLevelEntity();
488+
try {
489+
entity.setAgency(LogLevelEntity.LogLevel.ERROR);
490+
final CompletableFuture<LogLevelEntity> f = arangoDB.setLogLevel(entity);
491+
assertThat(f, is(notNullValue()));
492+
f.whenComplete((logLevel, ex) -> {
493+
assertThat(logLevel, is(notNullValue()));
494+
assertThat(logLevel.getAgency(), is(LogLevelEntity.LogLevel.ERROR));
495+
});
496+
f.get();
497+
} finally {
498+
entity.setAgency(LogLevelEntity.LogLevel.INFO);
499+
arangoDB.setLogLevel(entity);
500+
}
501+
}
471502
}

0 commit comments

Comments
 (0)