Skip to content

Commit 5fa392e

Browse files
committed
add items to log api
1 parent 2f3b5dd commit 5fa392e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/main/java/io/ipfs/api/IPFS.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public enum PinType {all, direct, indirect, recursive}
2929
private final int connectTimeoutMillis;
3030
private final int readTimeoutMillis;
3131
public final Key key = new Key();
32+
public final Log log = new Log();
3233
public final Pin pin = new Pin();
3334
public final Repo repo = new Repo();
3435
public final IPFSObject object = new IPFSObject();
@@ -253,6 +254,15 @@ public List<KeyInfo> rm(String name) throws IOException {
253254
}
254255
}
255256

257+
public class Log {
258+
public Map level(String subsystem, String logLevel) throws IOException {
259+
return retrieveMap("log/level?arg=" + subsystem + "&arg=" + logLevel);
260+
}
261+
public Map ls() throws IOException {
262+
return retrieveMap("log/ls");
263+
}
264+
}
265+
256266
/* 'ipfs repo' is a plumbing command used to manipulate the repo.
257267
*/
258268
public class Repo {

src/test/java/io/ipfs/api/APITest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ public void keys() throws IOException {
6969
Assert.assertTrue("removed key", remaining.equals(existing));
7070
}
7171

72+
@Test
73+
public void log() throws IOException {
74+
Map lsResult = ipfs.log.ls();
75+
Assert.assertTrue("Log ls", !lsResult.isEmpty());
76+
Map levelResult = ipfs.log.level("all", "info");
77+
Assert.assertTrue("Log level", ((String)levelResult.get("Message")).startsWith("Changed log level"));
78+
}
79+
7280
@Test
7381
public void ipldNode() {
7482
Function<Stream<Pair<String, CborObject>>, CborObject.CborMap> map =

0 commit comments

Comments
 (0)