返回介绍

3.10.15. Logs

发布于 2023-09-20 23:50:40 字数 5545 浏览 0 评论 0 收藏 0

Caution

Buildbot no longer supports Python 2.7 on the Buildbot master.

3.10.15. Logs

class buildbot.process.log.Log

This class handles write-only access to log files from running build steps. It does not provide an interface for reading logs - such access should occur directly through the Data API.

Instances of this class can only be created by the addLog method of a build step.

name

The name of the log.

Note that if you have a build step which outputs multiple logs, naming one of the logs Summary will cause the Web UI to sort the summary log first in the list, and expand it so that the contents are immediately visible.

type

The type of the log, represented as a single character. See logchunk for details.

logid

The ID of the logfile.

decoder

A callable used to decode bytestrings. See logEncoding.

subscribe(receiver)
Parameters:

receiver (callable) – the function to call

Register receiver to be called with line-delimited chunks of log data. The callable is invoked as receiver(stream, chunk), where the stream is indicated by a single character, or None for logs without streams. The chunk is a single string containing an arbitrary number of log lines, and terminated with a newline. When the logfile is finished, receiver will be invoked with None for both arguments.

The callable cannot return a Deferred. If it must perform some asynchronous operation, it will need to handle its own Deferreds, and be aware that multiple overlapping calls may occur.

Note that no “rewinding” takes place: only log content added after the call to subscribe will be supplied to receiver.

finish()
Returns:

Deferred

This method indicates that the logfile is finished. No further additions will be permitted.

In use, callers will receive a subclass with methods appropriate for the log type:

class buildbot.process.log.TextLog
addContent(text):
Parameters:

text – log content

Returns:

Deferred

Add the given data to the log. The data need not end on a newline boundary.

class buildbot.process.log.HTMLLog
addContent(text):
Parameters:

text – log content

Returns:

Deferred

Same as TextLog.addContent.

class buildbot.process.log.StreamLog

This class handles logs containing three interleaved streams: stdout, stderr, and header. The resulting log maintains data distinguishing these streams, so they can be filtered or displayed in different colors. This class is used to represent the stdio log in most steps.

addStdout(text)
Parameters:

text – log content

Returns:

Deferred

Add content to the stdout stream. The data need not end on a newline boundary.

addStderr(text)
Parameters:

text – log content

Returns:

Deferred

Add content to the stderr stream. The data need not end on a newline boundary.

addHeader(text)
Parameters:

text – log content

Returns:

Deferred

Add content to the header stream. The data need not end on a newline boundary.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文