Navigation

This is a base class for objects which receive logs from worker commands as they are produced.
It does not provide an interface for reading logs - such access should occur directly through the Data API.

The three methods that subclasses may override follow.
None of these methods may return a Deferred.
It is up to the callee to handle any asynchronous operations.
Subclasses may also override the constructor, with no need to call LogObserver's constructor.

outReceived(data):

Parameters:

data (unicode) -- received data

This method is invoked when a "chunk" of data arrives in the log.
The chunk contains one or more newline-terminated unicode lines.
For stream logs (e.g., stdio), output to stderr generates a call to errReceived, instead.

errReceived(data):

Parameters:

data (unicode) -- received data

This method is similar to outReceived, but is called for output to stderr.

headerReceived(data):

Parameters:

data (unicode) -- received data

This method is similar to outReceived, but is called for header output.

Each yield expression evaluates to a tuple of (stream, line), where the stream is one of 'o', 'e', or 'h' for stdout, stderr, and header, respectively.
As with any generator function, the yield expression will raise a GeneratorExit exception when the generator is complete.
To do something after the log is finished, just catch this exception (but then re-raise it or return)

This use of generator functions is a simple Python idiom first described in PEP 342.
It is unrelated to the generators used in inlineCallbacks.
In fact, consumers of this type are incompatible with asynchronous programming, as each line must be processed immediately.