From 930a458e77713c476cd430a027b6b2f3cc6b0723 Mon Sep 17 00:00:00 2001 From: Pierre Tardy Date: Mon, 22 Aug 2016 10:48:16 +0200 Subject: [PATCH] add some example in data api documentation for getting smaller set of logs --- master/buildbot/spec/types/logchunk.raml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/master/buildbot/spec/types/logchunk.raml b/master/buildbot/spec/types/logchunk.raml index c4f81e1ca6c..fafae08aee6 100644 --- a/master/buildbot/spec/types/logchunk.raml +++ b/master/buildbot/spec/types/logchunk.raml @@ -23,6 +23,18 @@ description: | These are specified as query parameters via the REST interface, or as arguments to the :py:meth:`~buildbot.data.connector.DataConnector.get` method in Python. The result will begin with line ``offset`` (so the resulting ``firstline`` will be equal to the given ``offset``), and will contain up to ``limit`` lines. + Following example will get the first 100 lines of a log:: + + from buildbot.data import resultspec + first_100_lines = yield self.master.data.get(("logs", log['logid'], "contents"), + resultSpec=resultspec.ResultSpec(limit=100)) + + Following example will get the last 100 lines of a log:: + + from buildbot.data import resultspec + last_100_lines = yield self.master.data.get(("logs", log['logid'], "contents"), + resultSpec=resultspec.ResultSpec(offset=log['num_lines']-100)) + .. note:: There is no event for a new chunk. Instead, the log resource is updated when new chunks are added, with the new number of lines.