clp_ffi_py.ir.readers module#

class clp_ffi_py.ir.readers.ClpIrFileReader[source]#

Bases: ClpIrStreamReader

Wrapper class of ClpIrStreamReader that calls open for convenience.

__init__(fpath, deserializer_buffer_size=65536, enable_compression=True, allow_incomplete_stream=False)[source]#
Parameters:
  • fpath (Path)

  • deserializer_buffer_size (int)

  • enable_compression (bool)

  • allow_incomplete_stream (bool)

dump(ostream=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>)[source]#
Parameters:

ostream (IO[str])

Return type:

None

class clp_ffi_py.ir.readers.ClpIrStreamReader[source]#

Bases: Iterator[LogEvent]

This class represents a stream reader used to read/deserialize log events from a CLP IR stream. It also provides method(s) to instantiate a log event generator with a customized search query.

Parameters:
  • istream – Input stream that contains CLP IR byte sequence.

  • deserializer_buffer_size – Initial size of the deserializer buffer.

  • enable_compression – A flag indicating whether the istream is compressed using zstd.

  • allow_incomplete_stream – If set to True, an incomplete CLP IR stream is not treated as an error. Instead, encountering such a stream is seen as reaching its end without raising any exceptions.

DEFAULT_DESERIALIZER_BUFFER_SIZE: int = 65536#
__init__(istream, deserializer_buffer_size=65536, enable_compression=True, allow_incomplete_stream=False)[source]#
Parameters:
  • istream (IO[bytes])

  • deserializer_buffer_size (int)

  • enable_compression (bool)

  • allow_incomplete_stream (bool)

close()[source]#
Return type:

None

get_metadata()[source]#
Return type:

Metadata

has_metadata()[source]#
Return type:

bool

read_next_log_event()[source]#

Reads and deserializes the next log event from the IR stream.

Returns:

  • Next unread log event represented as an instance of LogEvent.

  • None if the end of IR stream is reached.

Raises:

Exception – If deserialize_next_log_event() fails.

Return type:

LogEvent | None

read_preamble()[source]#

Try to deserialize the preamble and set metadata. If metadata has been set already, it will instantly return. It is separated from __init__ so that the input stream does not need to be readable on a reader’s construction, but until the user starts to iterate logs.

Raises:

Exception – If deserialize_preamble() fails.

Return type:

None

search(query)[source]#

Searches and yields log events that match a specific search query.

Parameters:

query (Query) – The input query object used to match log events. Check the document of Query for more details.

Yield:

The next unread log event that matches the given search query from the IR stream.

Return type:

Generator[LogEvent, None, None]